[RFC] proposed libc interface and man page for listmount
Florian Weimer
fweimer@redhat.com
Wed Dec 6 11:05:18 GMT 2023
* Miklos Szeredi:
> Attaching the proposed man page for listing mounts (based on the new
> listmount() syscall).
>
> The raw interface is:
>
> syscall(__NR_listmount, const struct mnt_id_req __user *, req,
> u64 __user *, buf, size_t, bufsize, unsigned int, flags);
>
> The proposed libc API is.
>
> struct listmount *listmount_start(uint64_t mnt_id, unsigned int flags);
> uint64_t listmount_next(struct listmount *lm);
> void listmount_end(struct listmount *lm);
>
> I'm on the opinion that no wrapper is needed for the raw syscall, just
> like there isn't one for getdents(2).
We do have a wrapper for getdents64. It's useful because if you modify
the directory, you care about the buffer boundary because you should
rewind after processing the current buffer. The inotify facility also
exposes a sequence of variably sized objects to applications, but does
not add a new system call for that. That's just an aside, though.
The existing functions dealing with /proc/mounts or /etc/fstab are
called setmntent, getmntent or getmntment_r (the former with a bad
implementation, the latter with a bad interface), and endmntent. This
follows the pattern of NSS enumeration interfaces, except that in the
mntent case, there is an explicit file handle, so a thread-safe
implementation is possible in principle. Your proposed interface is
similar, so that's good.
I would also like to see a comment from the Hurd folks. Presumably they
have something similar already for enumerating translators?
Thanks,
Florian
More information about the Libc-alpha
mailing list