From: Christian Brauner Date: Wed, 17 Aug 2022 07:44:34 +0000 (+0200) Subject: mount: move mount utilities from syscall_wrappers.h into mount_utils.h X-Git-Tag: v6.0.0~101^2~3 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=74c2f58e1fe8be16b0cee0e15f3152bccf74ad81;p=mirror_lxc.git mount: move mount utilities from syscall_wrappers.h into mount_utils.h Signed-off-by: Christian Brauner (Microsoft) --- diff --git a/src/lxc/conf.h b/src/lxc/conf.h index 772479f9e..82cb66a77 100644 --- a/src/lxc/conf.h +++ b/src/lxc/conf.h @@ -21,6 +21,7 @@ #include "list.h" #include "lxcseccomp.h" #include "memory_utils.h" +#include "mount_utils.h" #include "namespace.h" #include "ringbuf.h" #include "start.h" diff --git a/src/lxc/mount_utils.h b/src/lxc/mount_utils.h index dc30d4ad3..a76f7bd1f 100644 --- a/src/lxc/mount_utils.h +++ b/src/lxc/mount_utils.h @@ -176,6 +176,90 @@ struct lxc_rootfs; #define MOUNT_ATTR_IDMAP 0x00100000 #endif +#if !HAVE_MOVE_MOUNT +static inline int move_mount_lxc(int from_dfd, const char *from_pathname, + int to_dfd, const char *to_pathname, + unsigned int flags) +{ + return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, + to_pathname, flags); +} +#define move_mount move_mount_lxc +#else +extern int move_mount(int from_dfd, const char *from_pathname, int to_dfd, + const char *to_pathname, unsigned int flags); +#endif + +#if !HAVE_OPEN_TREE +static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flags) +{ + return syscall(__NR_open_tree, dfd, filename, flags); +} +#define open_tree open_tree_lxc +#else +extern int open_tree(int dfd, const char *filename, unsigned int flags); +#endif + +#if !HAVE_FSOPEN +static inline int fsopen_lxc(const char *fs_name, unsigned int flags) +{ + return syscall(__NR_fsopen, fs_name, flags); +} +#define fsopen fsopen_lxc +#else +extern int fsopen(const char *fs_name, unsigned int flags); +#endif + +#if !HAVE_FSPICK +static inline int fspick_lxc(int dfd, const char *path, unsigned int flags) +{ + return syscall(__NR_fspick, dfd, path, flags); +} +#define fspick fspick_lxc +#else +extern int fspick(int dfd, const char *path, unsigned int flags); +#endif + +#if !HAVE_FSCONFIG +static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const void *value, int aux) +{ + return syscall(__NR_fsconfig, fd, cmd, key, value, aux); +} +#define fsconfig fsconfig_lxc +#else +extern int fsconfig(int fd, unsigned int cmd, const char *key, const void *value, int aux); +#endif + +#if !HAVE_FSMOUNT +static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags) +{ + return syscall(__NR_fsmount, fs_fd, flags, attr_flags); +} +#define fsmount fsmount_lxc +#else +extern int fsmount(int fs_fd, unsigned int flags, unsigned int attr_flags); +#endif + +/* + * mount_setattr() + */ +#if !HAVE_STRUCT_MOUNT_ATTR +struct mount_attr { + __u64 attr_set; + __u64 attr_clr; + __u64 propagation; + __u64 userns_fd; +}; +#endif + +#if !HAVE_MOUNT_SETATTR +static inline int mount_setattr(int dfd, const char *path, unsigned int flags, + struct mount_attr *attr, size_t size) +{ + return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); +} +#endif + __hidden extern int mnt_attributes_new(unsigned int old_flags, unsigned int *new_flags); __hidden extern int mnt_attributes_old(unsigned int new_flags, unsigned int *old_flags); diff --git a/src/lxc/syscall_wrappers.h b/src/lxc/syscall_wrappers.h index 0710e0803..d5b7c3bf0 100644 --- a/src/lxc/syscall_wrappers.h +++ b/src/lxc/syscall_wrappers.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -144,90 +143,6 @@ static int faccessat(int __fd, const char *__file, int __type, int __flag) } #endif -#if !HAVE_MOVE_MOUNT -static inline int move_mount_lxc(int from_dfd, const char *from_pathname, - int to_dfd, const char *to_pathname, - unsigned int flags) -{ - return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, - to_pathname, flags); -} -#define move_mount move_mount_lxc -#else -extern int move_mount(int from_dfd, const char *from_pathname, int to_dfd, - const char *to_pathname, unsigned int flags); -#endif - -#if !HAVE_OPEN_TREE -static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flags) -{ - return syscall(__NR_open_tree, dfd, filename, flags); -} -#define open_tree open_tree_lxc -#else -extern int open_tree(int dfd, const char *filename, unsigned int flags); -#endif - -#if !HAVE_FSOPEN -static inline int fsopen_lxc(const char *fs_name, unsigned int flags) -{ - return syscall(__NR_fsopen, fs_name, flags); -} -#define fsopen fsopen_lxc -#else -extern int fsopen(const char *fs_name, unsigned int flags); -#endif - -#if !HAVE_FSPICK -static inline int fspick_lxc(int dfd, const char *path, unsigned int flags) -{ - return syscall(__NR_fspick, dfd, path, flags); -} -#define fspick fspick_lxc -#else -extern int fspick(int dfd, const char *path, unsigned int flags); -#endif - -#if !HAVE_FSCONFIG -static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const void *value, int aux) -{ - return syscall(__NR_fsconfig, fd, cmd, key, value, aux); -} -#define fsconfig fsconfig_lxc -#else -extern int fsconfig(int fd, unsigned int cmd, const char *key, const void *value, int aux); -#endif - -#if !HAVE_FSMOUNT -static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags) -{ - return syscall(__NR_fsmount, fs_fd, flags, attr_flags); -} -#define fsmount fsmount_lxc -#else -extern int fsmount(int fs_fd, unsigned int flags, unsigned int attr_flags); -#endif - -/* - * mount_setattr() - */ -#if !HAVE_STRUCT_MOUNT_ATTR -struct mount_attr { - __u64 attr_set; - __u64 attr_clr; - __u64 propagation; - __u64 userns_fd; -}; -#endif - -#if !HAVE_MOUNT_SETATTR -static inline int mount_setattr(int dfd, const char *path, unsigned int flags, - struct mount_attr *attr, size_t size) -{ - return syscall(__NR_mount_setattr, dfd, path, flags, attr, size); -} -#endif - /* * Arguments for how openat2(2) should open the target path. If only @flags and * @mode are non-zero, then openat2(2) operates very similarly to openat(2).