mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
linux: Add mount_setattr
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>
This commit is contained in:
parent
c3b02b6567
commit
af1aa36c61
8
NEWS
8
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.
|
||||
|
@ -305,6 +305,7 @@ libc {
|
||||
fsopen;
|
||||
fspick;
|
||||
move_mount;
|
||||
mount_setattr;
|
||||
open_tree;
|
||||
pidfd_open;
|
||||
pidfd_getfd;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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__':
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user