]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
linux: Add mount_setattr
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 24 Jun 2022 19:59:19 +0000 (16:59 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 5 Jul 2022 13:08:48 +0000 (10:08 -0300)
It was added on Linux 5.12 (2a1867219c7b27f928e2545782b86daaf9ad50bd)
to allow change the properties of a mount or a mount tree using file
descriptors which the new mount api is based on.

Checked on x86_64-linux-gnu.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
39 files changed:
NEWS
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/arc/libc.abilist
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/ia64/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/nios2/libc.abilist
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/sys/mount.h
sysdeps/unix/sysv/linux/syscalls.list
sysdeps/unix/sysv/linux/tst-mount-consts.py
sysdeps/unix/sysv/linux/tst-mount.c
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist

diff --git a/NEWS b/NEWS
index 3d14c659cccb8b774ce2bb9cf22c164c657ca4a0..dbf351b89511baeaffc00fafe381b5393cab6599 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -41,10 +41,10 @@ Major new features:
   have adverse impact.  It is incompatible with EDNS0 usage and DNSSEC
   validation by applications.
 
-* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, and open_tree
-  functions have been added.  They are part of the new Linux kernel mount
-  APIs that allow applications to more flexibly configure and operate on
-  filesystem mounts.  The new mount APIs are specifically designed to work
+* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, open_tree,
+  and mount_setattr have been added.  They are part of the new Linux kernel
+  mount APIs that allow applications to more flexibly configure and operate
+  on filesystem mounts.  The new mount APIs are specifically designed to work
   with namespaces.
 
 * localedef now accepts locale definition files encoded in UTF-8.
index b70530ef40c8a64ec230910331cb80efe2c1dd88..65d2ceda2c108785930aeba0e60d038b4eca8b1a 100644 (file)
@@ -305,6 +305,7 @@ libc {
     fsopen;
     fspick;
     move_mount;
+    mount_setattr;
     open_tree;
     pidfd_open;
     pidfd_getfd;
index 2a666d81359196d2f7ec791d622a2cb6326308ef..16d34b55c6b932a53d830cec387c164f21ae9960 100644 (file)
@@ -2620,6 +2620,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 41bd7c19596b0de8ed7e7c83427009076739a04e..3f794bea0f01d2cea3156f8a6e78fcf47104bdc5 100644 (file)
@@ -2717,6 +2717,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 198fdab2f79cc075b629262ff70e5fbab21eae66..072627810ce5cf0e285fe31c9550777e98a0b2f1 100644 (file)
@@ -2381,6 +2381,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 6fd4e75df2de8a01746f343ebb30f8f573a8b34d..dbd5f07e6e40f85c567f2c37ff299c5969c76b0e 100644 (file)
@@ -500,6 +500,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 3ec572b50f7cd9f6aa02b9d92d3c86dfd82fde13..0f02d79faa5c20b8f9eef0fcd840f7d72549370d 100644 (file)
@@ -497,6 +497,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 94f3deb3e5bedc9e2ac40252daf2c3e6c0f68681..11d3b36a78bfd4f197e71a18cd432ccee4108c42 100644 (file)
@@ -2656,6 +2656,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index a7deaf3e2642a2381ad64fc657a6c62cbed35d8f..5caa1321b15ea9f0a5127f6597db40a8f2483103 100644 (file)
@@ -2605,6 +2605,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 5f1a1bc4d0a29ee3858ed3f3176c70190927bfb9..276d7d5619687d3aaa906adeddd5ff0cf79c0c20 100644 (file)
@@ -2789,6 +2789,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 1af8a55836882bb5ef8fd118a2e9f1de0e6ced46..5e2249518e9790865ea0a1fb9969ed71bf194071 100644 (file)
@@ -2555,6 +2555,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index ad3a4b40085660d228fb31cb42de7bc6e101fa9f..802469a5b928478b2ef412b54ab6b06e529260ac 100644 (file)
@@ -501,6 +501,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 87e76f33a020022bbd31e358b7d444634ca10b3e..2f949397df5c89229ba774197d37eac855267d0c 100644 (file)
@@ -2732,6 +2732,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 73df42c7aa9f0be22e7ef5a47284e435c5abc512..f63cc9cd4c22aba0141252096785625ad5b7cdba 100644 (file)
@@ -2705,6 +2705,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 5c2e9365471de9af9031af48ebf72e13013e583a..88d2b707f9ef52b616bb0795965bfeda48b2180f 100644 (file)
@@ -2702,6 +2702,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 45919d27d6ca98c73bc3d73fc2b0c894b83d731b..6c2bc0ee78f66e90e7efd95904ddef8f59186dd4 100644 (file)
@@ -2697,6 +2697,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 8321b0efac6110bfd65aaf83d749bac353c6726c..09c9980d95febcf27684d9a119bb864e79aa657f 100644 (file)
@@ -2695,6 +2695,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index c7198646d24a6908b405caac7ffdc5fef5a2f651..763920ea8f8fb30fa60e1e7442e17dbfe42bff73 100644 (file)
@@ -2703,6 +2703,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 8b3cca2a5474424736fe3e22bccef97711c8c6f7..36d30558c1369dea59e0d228b1c959b3110f20f0 100644 (file)
@@ -2606,6 +2606,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 2f1595bb3550e6a956db374792fe39ee03177214..e4383fe46406c9fd566f8374366149aa06689eb3 100644 (file)
@@ -2744,6 +2744,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index d1d4e12d123823ec27722b082cd736b6a8e5474a..735a8eea7ea6d7d444a39b57e33ee768e92833fa 100644 (file)
@@ -2127,6 +2127,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 50c9fadaf0bb0ce836dfbc56f5263a483f841235..715dd31afe71530e1794cfcfa77e432e67577362 100644 (file)
@@ -2759,6 +2759,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 8998a560cd89f0123df2562f54d7ae995aa62b2a..ac4b69e5fc410a8aec092feb93c4a561308fc009 100644 (file)
@@ -2792,6 +2792,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index bca46bdbe536517e89046d29536691939589c788..fd42f1bc11aa4180c100ad51530146c07ab61a99 100644 (file)
@@ -2514,6 +2514,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 97f6d96cd6db12dcf73dcc3c7692a800d7b2928a..24688916ddc365798c749a7edf6a28f42c4f5f9e 100644 (file)
@@ -2816,6 +2816,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index f588745b2868e6caabdc8725f0433ab90b848384..536eddf9f1faf9cda5908f1f458cb9cf4b89b161 100644 (file)
@@ -2383,6 +2383,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 1acf8a4c5448b25c18e15654e5eba2faef917e65..214b4f1c87d5111e6bbba730f3c9bcdaa1dc6cb6 100644 (file)
@@ -2583,6 +2583,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 7c8b410f1a8dccf32be5e2b018097902217660a0..bd738a4eb8d6d7f2109543d0d771f5175f91b340 100644 (file)
@@ -2757,6 +2757,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index ba9317ee01b418c198a1d1fe7a3524f644e9fc63..170361236a18f0f88b21c104cb98a19338bde313 100644 (file)
@@ -2551,6 +2551,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 75fa8834f1d9e5bbea4e2f1dc73d6d31278f4cd3..88fcd03300df7ef517736110ece0dba85dfd6bf0 100644 (file)
@@ -2612,6 +2612,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 4a4f8ff33f0d29671766f93bd5bd335b497f9bc5..f1115ef46d16adf5e7a5ffd6bcb5837064e6eb76 100644 (file)
@@ -2609,6 +2609,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index d26671dba8bdcf87e7abdd69405a628ef559a726..6063da1acf316f87eed78a8994bac837ff9cda22 100644 (file)
@@ -2752,6 +2752,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 16c2a98ab544181e708336e385be1d9bc74da3c4..780d2c0987dfbbdd4defe510c5ed1e2b1ec4dd8e 100644 (file)
@@ -2578,6 +2578,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 534d05b3f54f7586f67ffe33d28210f8f8c32ef8..f965986ba8771af5441ee83b618831873f504340 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <fcntl.h>
 #include <features.h>
+#include <stdint.h>
+#include <stddef.h>
 #include <sys/ioctl.h>
 
 #define BLOCK_SIZE     1024
@@ -155,6 +157,17 @@ enum
 #define MOUNT_ATTR_NOSYMFOLLOW  0x00200000 /* Do not follow symlinks.  */
 
 
+/* For mount_setattr.  */
+struct mount_attr
+{
+  uint64_t attr_set;
+  uint64_t attr_clr;
+  uint64_t propagation;
+  uint64_t userns_fd;
+};
+
+#define MOUNT_ATTR_SIZE_VER0    32 /* sizeof first published struct */
+
 /* move_mount flags.  */
 #define MOVE_MOUNT_F_SYMLINKS   0x00000001 /* Follow symlinks on from path */
 #define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
@@ -240,6 +253,15 @@ extern int fspick (int __dfd, const char *__path, unsigned int __flags)
 extern int open_tree (int __dfd, const char *__filename, unsigned int __flags)
   __THROW;
 
+/* Change the mount properties of the mount or an entire mount tree.  If
+   PATH is a relative pathname, then it is interpreted relative to the
+   directory referred to by the file descriptor dirfd.  Otherwise if DFD is
+   the special value AT_FDCWD then PATH is interpreted relative to the current
+   working directory of the calling process.  */
+extern int mount_setattr (int __dfd, const char *__path, unsigned int __flags,
+                         struct mount_attr *__uattr, size_t __usize)
+  __THROW;
+
 __END_DECLS
 
 #endif /* _SYS_MOUNT_H */
index 493e68b834c8ec3e5473808e02ad27c7eaa20b7f..6420049e8b80b534acdb814243b39bc0e75a585b 100644 (file)
@@ -39,6 +39,7 @@ mincore               -       mincore         i:aUV   mincore
 mlock          -       mlock           i:bU    mlock
 mlockall       -       mlockall        i:i     mlockall
 mount          EXTRA   mount           i:sssUp __mount mount
+mount_setattr  EXTRA   mount_setattr   i:isUpU mount_setattr
 move_mount     EXTRA   move_mount      i:isisU move_mount
 munlock                -       munlock         i:aU    munlock
 munlockall     -       munlockall      i:      munlockall
index 82ab18d96345dd2185127341db58763032394fc8..a62f803123706c9e2cd71cafcd62a5131f87b7bf 100755 (executable)
@@ -56,7 +56,9 @@ def main():
         check('FSMOUNT_.*'),
         # MOVE_MOUNT__MASK may vary depending of the kernel version.
         check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK'),
-        check('OPEN_TREE_*'))
+        check('OPEN_TREE_*'),
+        # MOUNT_ATTR_SIZE_VER0 is used for mount_setattr.
+        check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0'))
     sys.exit(status)
 
 if __name__ == '__main__':
index 12a665f950e16e630c3b6e09cdcfcd3c34220c9b..502d7e3433f49a4a17d638cd03cbb3dfcc425785 100644 (file)
@@ -23,6 +23,9 @@
 #include <sys/wait.h>
 #include <sys/mount.h>
 
+_Static_assert (sizeof (struct mount_attr) == MOUNT_ATTR_SIZE_VER0,
+               "sizeof (struct mount_attr) != MOUNT_ATTR_SIZE_VER0");
+
 static void
 subprocess (void)
 {
@@ -67,10 +70,31 @@ subprocess (void)
 
   TEST_COMPARE (open_tree (AT_FDCWD, "", 0), -1);
   TEST_COMPARE (errno, ENOENT);
+  int fd_tree = open_tree (AT_FDCWD, "/tmp",
+                          OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+  TEST_VERIFY (fd_tree != -1);
+
   {
-    int fd_tree = open_tree (AT_FDCWD, "/tmp",
-                            OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
-    TEST_VERIFY (fd_tree != -1);
+    struct mount_attr attr =
+    {
+      .attr_set = MOUNT_ATTR_RDONLY,
+    };
+     mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+                          sizeof (attr));
+    int r = mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+                          sizeof (attr));
+    /* New mount API was added on 5.1, but mount_setattr on 5.12.  */
+    if (r == -1)
+      TEST_COMPARE (errno, ENOSYS);
+    else
+      {
+       TEST_COMPARE (mount_setattr (-1, "", AT_EMPTY_PATH, &attr,
+                                    sizeof (attr)), -1);
+       TEST_COMPARE (errno, EBADF);
+       TEST_COMPARE (mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+                                    sizeof (attr) - 8), -1);
+       TEST_COMPARE (errno, EINVAL);
+      }
   }
 
   _exit (0);
index bd7c4ef801d8be1665b6a1b34453265e47260160..56cad609fe524d1f12cad935f76cab1392475dfc 100644 (file)
@@ -2529,6 +2529,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
index 1c7f60b41af8dbf87a2c001fb6fe0e0412095744..2ed242a62dc7bb733fcb675c810222cd09b986cb 100644 (file)
@@ -2635,6 +2635,7 @@ GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F