Linux 6.8 Introduces New Syscalls For More Detailed File-System Mount Information
Merged back at the start of the Linux 6.8 merge window were the VFS mount API updates that introduce two new system calls: statmount() and listmount() for reading more detailed information about file-system mounts.
The new statmount() and listmount() system calls stem from ongoing discussions around reliably retrieving mount information as well as introducing new 64-bit mount IDs
Linux engineer Christian Brauner at Microsoft explained of the new system calls:
Those interested in more information on the new statmount and listmount system calls being introduced in Linux 6.8 can find the details via this pull.
The new statmount() and listmount() system calls stem from ongoing discussions around reliably retrieving mount information as well as introducing new 64-bit mount IDs
Linux engineer Christian Brauner at Microsoft explained of the new system calls:
statmount() mimicks the semantics of statx() and exposes a set flags that userspace may raise in mnt_id_req to request specific information to be retrieved. A statmount() call returns a struct statmount filled in with information about the requested mount. Supported requests are indicated by raising the request flag passed in struct mnt_id_req in the @mask argument in struct statmount. Currently we do support:
* STATMOUNT_SB_BASIC:
Basic filesystem info.
* STATMOUNT_MNT_BASIC
Mount information (mount id, parent mount id, mount attributes etc.).
* STATMOUNT_PROPAGATE_FROM
Propagation from what mount in current namespace.
* STATMOUNT_MNT_ROOT
Path of the root of the mount (e.g., mount --bind /bla /mnt returns /bla).
* STATMOUNT_MNT_POINT
Path of the mount point (e.g., mount --bind /bla /mnt returns /mnt).
* STATMOUNT_FS_TYPE
Name of the filesystem type as the magic number isn't enough due to submounts.
...
listmount() is given a 64bit mount id via mnt_id_req just as statmount(). It takes a buffer and a size to return an array of the 64bit ids of the child mounts of the requested mount. Userspace can thus choose to either retrieve child mounts for a mount in batches or iterate through the child mounts. For most use-cases it will be sufficient to just leave space for a few child mounts. But for big mount tables having an iterator is really helpful.
Those interested in more information on the new statmount and listmount system calls being introduced in Linux 6.8 can find the details via this pull.
2 Comments