[PATCH v2 15/25] linux: Add statmount and listmount
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Nov 10 15:09:59 GMT 2026
The statmount (commit 46eae99ef73302f9fb3dddcd67c374b3dffe8fd6) and
listmount (commit b4c2bea8ceaa50cd42a8f73667389d801a3ecf2d) system
calls were added in Linux 6.8. They retrieve information about a mount
and list the mounts of a mount namespace, using the unique 64-bit mount
IDs (also returned by statx with STATX_MNT_ID_UNIQUE), and are the
replacement for parsing /proc/self/mountinfo (libmount uses them for
instance).
int statmount (const struct mnt_id_req *req, struct statmount *buf,
size_t bufsize, unsigned int flags);
ssize_t listmount (const struct mnt_id_req *req, uint64_t *mnt_ids,
size_t nr_mnt_ids, unsigned int flags);
The <sys/mount.h> now provides struct mnt_id_req, struct statmount, and
the STATMOUNT_*, LISTMOUNT_*, LSMT_ROOT, and MNT_ID_REQ_SIZE_* constants
as of Linux 7.3. As done for struct mount_attr, the structures are only
defined if <linux/mount.h> does not provide them, and the constants
follow the kernel definitions (which did not change since they were
added).
Checked on x86_64-linux-gnu.
---
NEWS | 4 +
sysdeps/unix/sysv/linux/Makefile | 1 +
sysdeps/unix/sysv/linux/Versions | 2 +
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 2 +
sysdeps/unix/sysv/linux/arc/libc.abilist | 2 +
sysdeps/unix/sysv/linux/arm/be/libc.abilist | 2 +
sysdeps/unix/sysv/linux/arm/le/libc.abilist | 2 +
sysdeps/unix/sysv/linux/csky/libc.abilist | 2 +
sysdeps/unix/sysv/linux/hppa/libc.abilist | 2 +
sysdeps/unix/sysv/linux/i386/libc.abilist | 2 +
.../sysv/linux/loongarch/ilp32/libc.abilist | 2 +
.../sysv/linux/loongarch/lp64/libc.abilist | 2 +
.../sysv/linux/m68k/coldfire/libc.abilist | 2 +
.../unix/sysv/linux/m68k/m680x0/libc.abilist | 2 +
.../sysv/linux/microblaze/be/libc.abilist | 2 +
.../sysv/linux/microblaze/le/libc.abilist | 2 +
.../sysv/linux/mips/mips32/fpu/libc.abilist | 2 +
.../sysv/linux/mips/mips32/nofpu/libc.abilist | 2 +
.../sysv/linux/mips/mips64/n32/libc.abilist | 2 +
.../sysv/linux/mips/mips64/n64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/or1k/libc.abilist | 2 +
.../linux/powerpc/powerpc32/fpu/libc.abilist | 2 +
.../powerpc/powerpc32/nofpu/libc.abilist | 2 +
.../linux/powerpc/powerpc64/be/libc.abilist | 2 +
.../linux/powerpc/powerpc64/le/libc.abilist | 2 +
.../unix/sysv/linux/riscv/rv32/libc.abilist | 2 +
.../unix/sysv/linux/riscv/rv64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/s390/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sh/be/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sh/le/libc.abilist | 2 +
.../sysv/linux/sparc/sparc32/libc.abilist | 2 +
.../sysv/linux/sparc/sparc64/libc.abilist | 2 +
sysdeps/unix/sysv/linux/sys/mount.h | 108 ++++++++++++
sysdeps/unix/sysv/linux/syscalls.list | 2 +
sysdeps/unix/sysv/linux/tst-mount-consts.py | 6 +-
sysdeps/unix/sysv/linux/tst-statmount.c | 162 ++++++++++++++++++
.../unix/sysv/linux/x86_64/64/libc.abilist | 2 +
.../unix/sysv/linux/x86_64/x32/libc.abilist | 2 +
39 files changed, 348 insertions(+), 1 deletion(-)
create mode 100644 sysdeps/unix/sysv/linux/tst-statmount.c
diff --git a/NEWS b/NEWS
index 6367afb3c22..722b7b53c6c 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,10 @@ Major new features:
It opens a mount tree as open_tree, and also changes the properties of
the new mount as mount_setattr.
+* On Linux, the statmount and listmount functions have been added to
+ <sys/mount.h>. They retrieve information about a mount and list the
+ mounts of a mount namespace, using the unique 64-bit mount IDs.
+
Deprecated and removed features, and other changes affecting compatibility:
* The posix_spawn_file_actions_addchdir and posix_spawn_file_actions_addfchdir
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 822f0220c07..cade5c1ea23 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -238,6 +238,7 @@ tests += \
tst-sched_setattr-thread \
tst-scm_rights \
tst-sigtimedwait \
+ tst-statmount \
tst-sync_file_range \
tst-syscall-restart \
tst-syscall-upper-bits \
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index e75fedff12e..077f6f56f06 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -345,8 +345,10 @@ libc {
}
GLIBC_2.45 {
fchroot;
+ listmount;
membarrier;
open_tree_attr;
+ statmount;
}
GLIBC_PRIVATE {
# functions used in other libraries
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 9e0b244a09e..0699c2cf346 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2776,7 +2776,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 2d0fd09831f..f91a8a8cf7b 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -3123,10 +3123,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index 2faed46dcf3..d1244ec47c9 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -2537,7 +2537,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 4e6c04ebfb4..81f56162dea 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -2829,10 +2829,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 13881353b19..0dcd5fdbabf 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -2826,10 +2826,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 2f855329ad5..d161a5b9a02 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2813,7 +2813,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index dc11106d5e2..4553ef1487c 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2850,10 +2850,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index aef1503707a..ff99362c816 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -3033,10 +3033,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist
index 12733e55827..51973b6b340 100644
--- a/sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist
@@ -2288,7 +2288,9 @@ GLIBC_2.44 write F
GLIBC_2.44 writev F
GLIBC_2.44 wscanf F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
index 95434ab4c14..b6bf7c3c797 100644
--- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
@@ -2297,7 +2297,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index a67f75b4816..b3eacffcafe 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -2809,10 +2809,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index c68865e63e4..3abfd1ac360 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2976,10 +2976,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 6ad74effdb4..2269b1d4ffd 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2862,7 +2862,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 8acd836d825..02f5957746b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2859,7 +2859,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 15edd7286de..610a6713057 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2939,10 +2939,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index c127af2eab7..ff8ca5b5931 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2937,10 +2937,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index 26b2d3691cb..04469c5f5bb 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2945,10 +2945,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index debd74e2808..e7fdcd5e0a8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2847,10 +2847,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
index c56e1c8b579..91df46305c7 100644
--- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
+++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
@@ -2287,7 +2287,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 2fdc6e18d72..090049d898b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -3166,10 +3166,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 6d8a9000a62..6236851c8d6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -3211,10 +3211,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index 0d55b3cacec..e29be4024c5 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2920,10 +2920,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index f0c6847b7c6..a946b14a152 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2996,7 +2996,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index b22ddf5122d..1bd90f0ccd3 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -2540,7 +2540,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 42e2daa1aa0..95e3c304f3a 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2740,7 +2740,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
diff --git a/sysdeps/unix/sysv/linux/s390/libc.abilist b/sysdeps/unix/sysv/linux/s390/libc.abilist
index c1d66b10eb9..db715993be0 100644
--- a/sysdeps/unix/sysv/linux/s390/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/libc.abilist
@@ -2957,10 +2957,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index fbd91250707..2fc2ad65386 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2856,10 +2856,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index b683288327b..2a67c8539bf 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2853,10 +2853,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 98f8c35b269..b395d183c2b 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -3187,10 +3187,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 22aa7f20c52..24f418dba67 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2823,10 +2823,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index d2fa28a69f4..f7ea5a3baa6 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -22,6 +22,7 @@
#define _SYS_MOUNT_H 1
#include <features.h>
+#include <sys/types.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/ioctl.h>
@@ -279,6 +280,100 @@ enum fsconfig_command
# define OPEN_TREE_CLOEXEC O_CLOEXEC /* Close the file on execve() */
#endif
+#ifndef MNT_ID_REQ_SIZE_VER0
+/* Mount ID and parameters for statmount and listmount. For statmount,
+ PARAM is the request mask; for listmount, it is the last listed mount ID
+ (or zero). */
+struct mnt_id_req
+{
+ uint32_t size;
+ __extension__ union
+ {
+ uint32_t mnt_ns_fd;
+ uint32_t mnt_fd;
+ };
+ uint64_t mnt_id;
+ uint64_t param;
+ uint64_t mnt_ns_id;
+};
+
+/* Information returned by statmount. The [str] fields are offsets of
+ strings in STR. */
+struct statmount
+{
+ uint32_t size; /* Total size, including strings. */
+ uint32_t mnt_opts; /* [str] Options (comma separated,
+ escaped). */
+ uint64_t mask; /* What results were written. */
+ uint32_t sb_dev_major; /* Device ID. */
+ uint32_t sb_dev_minor;
+ uint64_t sb_magic; /* ..._SUPER_MAGIC. */
+ uint32_t sb_flags; /* SB_{RDONLY,SYNCHRONOUS,DIRSYNC,
+ LAZYTIME}. */
+ uint32_t fs_type; /* [str] Filesystem type. */
+ uint64_t mnt_id; /* Unique ID of mount. */
+ uint64_t mnt_parent_id; /* Unique ID of parent (for root ==
+ mnt_id). */
+ uint32_t mnt_id_old; /* Reused IDs used in /proc/.../mountinfo. */
+ uint32_t mnt_parent_id_old;
+ uint64_t mnt_attr; /* MOUNT_ATTR_... */
+ uint64_t mnt_propagation; /* MS_{SHARED,SLAVE,PRIVATE,UNBINDABLE}. */
+ uint64_t mnt_peer_group; /* ID of shared peer group. */
+ uint64_t mnt_master; /* Mount receives propagation from this ID. */
+ uint64_t propagate_from; /* Propagation from in current namespace. */
+ uint32_t mnt_root; /* [str] Root of mount relative to root of
+ fs. */
+ uint32_t mnt_point; /* [str] Mountpoint relative to current
+ root. */
+ uint64_t mnt_ns_id; /* ID of the mount namespace. */
+ uint32_t fs_subtype; /* [str] Subtype of fs_type (if any). */
+ uint32_t sb_source; /* [str] Source string of the mount. */
+ uint32_t opt_num; /* Number of fs options. */
+ uint32_t opt_array; /* [str] Array of nul terminated fs
+ options. */
+ uint32_t opt_sec_num; /* Number of security options. */
+ uint32_t opt_sec_array; /* [str] Array of nul terminated security
+ options. */
+ uint64_t supported_mask; /* Mask flags that this kernel supports. */
+ uint32_t mnt_uidmap_num; /* Number of uid mappings. */
+ uint32_t mnt_uidmap; /* [str] Array of uid mappings. */
+ uint32_t mnt_gidmap_num; /* Number of gid mappings. */
+ uint32_t mnt_gidmap; /* [str] Array of gid mappings. */
+ uint64_t __spare2[43];
+ char str __flexarr; /* Variable size part containing strings. */
+};
+#endif
+#define MNT_ID_REQ_SIZE_VER0 24 /* sizeof first published struct */
+#define MNT_ID_REQ_SIZE_VER1 32 /* sizeof second published struct */
+
+/* Request mask bits for statmount. */
+#define STATMOUNT_SB_BASIC 0x00000001U /* Want/got sb_... */
+#define STATMOUNT_MNT_BASIC 0x00000002U /* Want/got mnt_... */
+#define STATMOUNT_PROPAGATE_FROM 0x00000004U /* Want/got
+ propagate_from. */
+#define STATMOUNT_MNT_ROOT 0x00000008U /* Want/got mnt_root. */
+#define STATMOUNT_MNT_POINT 0x00000010U /* Want/got mnt_point. */
+#define STATMOUNT_FS_TYPE 0x00000020U /* Want/got fs_type. */
+#define STATMOUNT_MNT_NS_ID 0x00000040U /* Want/got mnt_ns_id. */
+#define STATMOUNT_MNT_OPTS 0x00000080U /* Want/got mnt_opts. */
+#define STATMOUNT_FS_SUBTYPE 0x00000100U /* Want/got fs_subtype. */
+#define STATMOUNT_SB_SOURCE 0x00000200U /* Want/got sb_source. */
+#define STATMOUNT_OPT_ARRAY 0x00000400U /* Want/got opt_... */
+#define STATMOUNT_OPT_SEC_ARRAY 0x00000800U /* Want/got opt_sec... */
+#define STATMOUNT_SUPPORTED_MASK 0x00001000U /* Want/got supported
+ mask flags. */
+#define STATMOUNT_MNT_UIDMAP 0x00002000U /* Want/got uidmap... */
+#define STATMOUNT_MNT_GIDMAP 0x00004000U /* Want/got gidmap... */
+
+/* statmount flags. */
+#define STATMOUNT_BY_FD 0x00000001U /* Want mountinfo for given
+ fd. */
+
+/* Special mount ID for listmount: the root mount. */
+#define LSMT_ROOT 0xffffffffffffffff
+/* listmount flags. */
+#define LISTMOUNT_REVERSE (1 << 0) /* List later mounts first. */
+
__BEGIN_DECLS
/* Mount a filesystem. */
@@ -337,6 +432,19 @@ extern int open_tree_attr (int __dfd, const char *__filename,
unsigned int __flags, struct mount_attr *__uattr,
size_t __usize) __THROW;
+/* Store in BUF, of size BUFSIZE, the information selected by the
+ REQ->param mask about the mount REQ->mnt_id. */
+extern int statmount (const struct mnt_id_req *__req,
+ struct statmount *__buf, size_t __bufsize,
+ unsigned int __flags) __THROW;
+
+/* Store in MNT_IDS, with room for NR_MNT_IDS entries, the IDs of the mounts
+ below the mount REQ->mnt_id (or LSMT_ROOT) which come after the mount ID
+ REQ->param (or from the start if it is zero). Return the number of
+ stored IDs. */
+extern ssize_t listmount (const struct mnt_id_req *__req, uint64_t *__mnt_ids,
+ size_t __nr_mnt_ids, unsigned int __flags) __THROW;
+
__END_DECLS
#endif /* _SYS_MOUNT_H */
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index a53fd6d6b42..99e138a699a 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -34,6 +34,7 @@ ioperm - ioperm i:UUi ioperm
iopl - iopl i:i iopl
klogctl EXTRA syslog i:isi klogctl
lchown - lchown i:sii __lchown lchown
+listmount EXTRA listmount i:ppUU listmount
membarrier EXTRA membarrier i:iUi membarrier
mincore - mincore i:aUV mincore
mlock - mlock i:bU mlock
@@ -68,6 +69,7 @@ setfsgid EXTRA setfsgid i:i setfsgid
setfsuid EXTRA setfsuid i:i setfsuid
setpgid - setpgid i:ii __setpgid setpgid
sigaltstack - sigaltstack i:PP __sigaltstack sigaltstack
+statmount EXTRA statmount i:ppUU statmount
sysinfo EXTRA sysinfo i:p __sysinfo sysinfo
swapon - swapon i:si __swapon swapon
swapoff - swapoff i:s __swapoff swapoff
diff --git a/sysdeps/unix/sysv/linux/tst-mount-consts.py b/sysdeps/unix/sysv/linux/tst-mount-consts.py
index 027fd12dff0..04ba1242c5d 100755
--- a/sysdeps/unix/sysv/linux/tst-mount-consts.py
+++ b/sysdeps/unix/sysv/linux/tst-mount-consts.py
@@ -63,7 +63,11 @@ def main():
check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK'),
check('OPEN_TREE_*'),
# MOUNT_ATTR_SIZE_VER0 is used for mount_setattr.
- check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0'))
+ check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0'),
+ check('MNT_ID_REQ_.*'),
+ check('STATMOUNT_.*'),
+ check('LISTMOUNT_.*'),
+ check('LSMT_.*'))
sys.exit(status)
if __name__ == '__main__':
diff --git a/sysdeps/unix/sysv/linux/tst-statmount.c b/sysdeps/unix/sysv/linux/tst-statmount.c
new file mode 100644
index 00000000000..641a1069f85
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-statmount.c
@@ -0,0 +1,162 @@
+/* Basic tests for Linux statmount and listmount.
+ Copyright (C) 2026 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <support/check.h>
+#include <support/namespace.h>
+#include <support/support.h>
+#include <support/xunistd.h>
+
+_Static_assert (sizeof (struct mnt_id_req) >= MNT_ID_REQ_SIZE_VER0,
+ "unexpected struct mnt_id_req size");
+
+#define MAX_MOUNTS 1024
+static uint64_t ids[MAX_MOUNTS];
+static uint64_t ids_rev[MAX_MOUNTS];
+
+/* Large enough for the three strings returned by the kernel. */
+#define BUFSIZE (64 * 1024)
+
+static int
+do_test (void)
+{
+ bool private_ns = false;
+ if (support_become_root ())
+ private_ns = support_enter_mount_namespace ();
+
+ struct mnt_id_req req =
+ {
+ .size = sizeof (req),
+ .mnt_id = LSMT_ROOT,
+ };
+ ssize_t n = listmount (&req, ids, MAX_MOUNTS, 0);
+ if (n == -1 && errno == ENOSYS)
+ FAIL_UNSUPPORTED ("listmount is not supported by the kernel");
+ TEST_VERIFY_EXIT (n > 0);
+ printf ("info: %zd mounts\n", n);
+
+ /* The mount IDs are listed in increasing order. */
+ for (ssize_t i = 1; i < n; i++)
+ TEST_VERIFY (ids[i - 1] < ids[i]);
+
+ /* Restart the listing after the first ID. The mount table might change if
+ the test does not run in its own mount namespace. */
+ if (private_ns && n > 1)
+ {
+ req.param = ids[0];
+ TEST_COMPARE (listmount (&req, ids_rev, n - 1, 0), n - 1);
+ TEST_COMPARE_BLOB (ids_rev, (n - 1) * sizeof (ids[0]),
+ &ids[1], (n - 1) * sizeof (ids[0]));
+ req.param = 0;
+ }
+
+ /* LISTMOUNT_REVERSE was added in Linux 6.11, and listmount rejects any flag
+ before that. */
+ if (private_ns && n < MAX_MOUNTS)
+ {
+ ssize_t r = listmount (&req, ids_rev, MAX_MOUNTS, LISTMOUNT_REVERSE);
+ if (r == -1 && errno == EINVAL)
+ puts ("info: LISTMOUNT_REVERSE not supported by the kernel");
+ else
+ {
+ TEST_COMPARE (r, n);
+ for (ssize_t i = 0; i < n; i++)
+ TEST_COMPARE (ids_rev[i], ids[n - 1 - i]);
+ }
+ }
+
+ TEST_COMPARE (listmount (&req, ids, MAX_MOUNTS, LISTMOUNT_REVERSE << 1),
+ -1);
+ TEST_COMPARE (errno, EINVAL);
+
+ /* Check the root mount against statx. */
+ struct statx stx;
+ TEST_COMPARE (statx (AT_FDCWD, "/", 0, STATX_MNT_ID_UNIQUE, &stx), 0);
+ TEST_VERIFY_EXIT (stx.stx_mask & STATX_MNT_ID_UNIQUE);
+
+ struct statmount *sm = xmalloc (BUFSIZE);
+ req.mnt_id = stx.stx_mnt_id;
+ req.param = STATMOUNT_SB_BASIC | STATMOUNT_MNT_BASIC | STATMOUNT_MNT_POINT
+ | STATMOUNT_FS_TYPE;
+ TEST_COMPARE (statmount (&req, sm, BUFSIZE, 0), 0);
+ TEST_VERIFY (sm->size <= BUFSIZE);
+ TEST_COMPARE (sm->mask & req.param, req.param);
+ TEST_COMPARE (sm->mnt_id, stx.stx_mnt_id);
+ /* The device numbers reported by statx can differ from the superblock ones
+ (for example, for btrfs subvolumes), so check the file system type
+ instead. */
+ struct statfs sfs;
+ TEST_COMPARE (statfs ("/", &sfs), 0);
+ TEST_COMPARE ((uint32_t) sm->sb_magic, (uint32_t) sfs.f_type);
+ TEST_COMPARE_STRING (sm->str + sm->mnt_point, "/");
+ TEST_VERIFY (sm->str[sm->fs_type] != '\0');
+ printf ("info: / is a %s mount\n", sm->str + sm->fs_type);
+
+ /* Every listed mount can be queried. */
+ req.param = STATMOUNT_MNT_BASIC;
+ for (ssize_t i = 0; i < n; i++)
+ {
+ req.mnt_id = ids[i];
+ if (statmount (&req, sm, BUFSIZE, 0) == 0)
+ TEST_COMPARE (sm->mnt_id, ids[i]);
+ else
+ /* The mount might have been removed meanwhile. */
+ TEST_VERIFY (!private_ns && errno == ENOENT);
+ }
+
+ /* The mount ID must be valid. Linux 6.8 to 6.10 report it as an unknown
+ mount. */
+ req.mnt_id = 0;
+ TEST_COMPARE (statmount (&req, sm, BUFSIZE, 0), -1);
+ TEST_VERIFY (errno == EINVAL || errno == ENOENT);
+
+ /* Query the mount by file descriptor. The descriptor goes in the field
+ after SIZE, which kernel headers older than Linux 7.0 do not call
+ mnt_fd. */
+ {
+ _Static_assert (offsetof (struct mnt_id_req, mnt_id)
+ == 2 * sizeof (uint32_t), "mnt_fd follows size");
+ int fd = xopen ("/", O_PATH, 0);
+ uint32_t mnt_fd = fd;
+ req.mnt_id = 0;
+ memcpy ((char *) &req + sizeof (req.size), &mnt_fd, sizeof (mnt_fd));
+ if (statmount (&req, sm, BUFSIZE, STATMOUNT_BY_FD) == 0)
+ TEST_COMPARE (sm->mnt_id, stx.stx_mnt_id);
+ else
+ {
+ TEST_COMPARE (errno, EINVAL);
+ puts ("info: STATMOUNT_BY_FD not supported by the kernel");
+ }
+ xclose (fd);
+ }
+
+ free (sm);
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index d17b6fe56f0..13dd8046223 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2772,10 +2772,12 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
GLIBC_2.5 __readlinkat_chk F
GLIBC_2.5 inet6_opt_append F
GLIBC_2.5 inet6_opt_find F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 5fa004c4769..ee71892763d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2791,7 +2791,9 @@ GLIBC_2.43 mseal F
GLIBC_2.43 openat2 F
GLIBC_2.43 umaxabs F
GLIBC_2.45 fchroot F
+GLIBC_2.45 listmount F
GLIBC_2.45 membarrier F
GLIBC_2.45 open_tree_attr F
GLIBC_2.45 posix_spawn_file_actions_addchdir F
GLIBC_2.45 posix_spawn_file_actions_addfchdir F
+GLIBC_2.45 statmount F
--
2.53.0
More information about the Libc-alpha
mailing list