Skip to content

Commit

Permalink
mount: move mount utilities from syscall_wrappers.h into mount_utils.h
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner (Microsoft) <christian.brauner@ubuntu.com>
  • Loading branch information
brauner authored and stgraber committed Dec 16, 2022
1 parent d5d7e20 commit 460243f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 85 deletions.
1 change: 1 addition & 0 deletions src/lxc/conf.h
Expand Up @@ -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"
Expand Down
84 changes: 84 additions & 0 deletions src/lxc/mount_utils.h
Expand Up @@ -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);
Expand Down
85 changes: 0 additions & 85 deletions src/lxc/syscall_wrappers.h
Expand Up @@ -10,7 +10,6 @@
#include <linux/keyctl.h>
#include <sched.h>
#include <stdint.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
#include <sys/types.h>
Expand Down Expand Up @@ -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).
Expand Down

0 comments on commit 460243f

Please sign in to comment.