From: "Zack Weinberg" <zack@owlfolio.org>
To: "Ian Kent" <ikent@redhat.com>,
"Miklos Szeredi" <miklos@szeredi.hu>,
"Ian Kent" <raven@themaw.net>
Cc: "Florian Weimer" <fweimer@redhat.com>,
"GNU libc development" <libc-alpha@sourceware.org>,
'linux-man' <linux-man@vger.kernel.org>,
"Alejandro Colomar" <alx@kernel.org>,
"Linux API" <linux-api@vger.kernel.org>,
linux-fsdevel@vger.kernel.org, "Karel Zak" <kzak@redhat.com>,
"David Howells" <dhowells@redhat.com>,
"Christian Brauner" <christian@brauner.io>,
"Amir Goldstein" <amir73il@gmail.com>,
"Arnd Bergmann" <arnd@arndb.de>
Subject: Re: proposed libc interface and man page for statmount(2)
Date: Wed, 22 Nov 2023 11:18:12 -0500 [thread overview]
Message-ID: <8a21bcea-ba93-4b3c-b99e-bb9f735c5755@app.fastmail.com> (raw)
In-Reply-To: <698dd63e-9cd8-2d22-c4ca-d8138ed97606@redhat.com>
On Tue, Nov 21, 2023, at 6:28 PM, Ian Kent wrote:
> On 22/11/23 04:42, Zack Weinberg wrote:
>> On Tue, Nov 21, 2023, at 2:42 PM, Miklos Szeredi wrote:
>>> handle = listmount_open(mnt_id, flags);
>>> for (;;) {
>>> child_id = listmount_next(handle);
>>> if (child_id == 0)
>>> break;
>>> /* do something with child_id */
>>> }
>>> listmount_close(handle)
>>
>> Why can't these be plain old open, read, and close? Starting from a pathname
>> in /proc or /sys. Doesn't allow lseek.
>
> I'm not sure how this would work, there aren't a series of paths in proc
> that represent mounts?
It would be a new one created for this purpose.
listmount_open(mnt_id, flags) ==
open("/proc/mount_ids", O_RDONLY) +
ioctl(fd, LISTMNT_QUERY_ID, mnt_id) +
ioctl(fd, LISTMNT_QUERY_FLAGS, flags)
and then read(fd, buf, sizeof(buf)) gives you sizeof(buf)/sizeof(mntid_t)
mount IDs.
Or, if you prefer, keep the new listmount_open() system call but have it
return a file descriptor that acts like a pipe filled with all the child
mount IDs. The main point of my suggestion is that listmount_next and
listmount_close can, and should (IMO), just be read() and close().
Note that I'm _not_ suggesting a text-based interface like most of /proc.
What you read is native-endian binary mount IDs.
> One is that open() is a fairly high overhead system call and it so it
> won't cope well with traversing a large volume of mounts.
...
> Second is that, because the mount table lives in a file (actually more
> than one with slightly different formats) it needs to be traversed every
> time one is looking for a mount which has been shown to be high overhead,
Does my clarified explanation address these concerns?
zw
next prev parent reply other threads:[~2023-11-22 16:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 15:08 proposed libc interface and man page for statmount(2) Miklos Szeredi
2023-11-16 20:12 ` Adhemerval Zanella Netto
2023-11-16 20:36 ` Florian Weimer
2023-11-16 21:01 ` Miklos Szeredi
2023-11-17 14:22 ` Miklos Szeredi
2023-11-17 14:47 ` Florian Weimer
2023-11-17 15:13 ` Miklos Szeredi
2023-11-17 15:50 ` Miklos Szeredi
2023-11-20 11:55 ` Miklos Szeredi
2023-11-20 12:16 ` Florian Weimer
2023-11-20 12:34 ` Miklos Szeredi
2023-11-20 23:56 ` Ian Kent
2023-11-21 0:58 ` Ian Kent
2023-11-21 1:12 ` Ian Kent
2023-11-21 1:33 ` Ian Kent
2023-11-21 19:42 ` Miklos Szeredi
2023-11-21 20:42 ` Zack Weinberg
2023-11-21 23:28 ` Ian Kent
2023-11-22 16:18 ` Zack Weinberg [this message]
2023-11-21 23:07 ` Ian Kent
2023-11-22 10:18 ` Christian Brauner
2023-11-20 15:38 ` Christian Brauner
2023-11-20 15:30 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a21bcea-ba93-4b3c-b99e-bb9f735c5755@app.fastmail.com \
--to=zack@owlfolio.org \
--cc=alx@kernel.org \
--cc=amir73il@gmail.com \
--cc=arnd@arndb.de \
--cc=christian@brauner.io \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=ikent@redhat.com \
--cc=kzak@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).