Linux 6.8 Introduces New Syscalls For More Detailed File-System Mount Information

Written by Michael Larabel in Linux Storage on 16 January 2024 at 06:28 AM EST. 2 Comments
LINUX STORAGE
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:
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.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week