1
0
mirror of https://github.com/systemd/systemd synced 2024-07-08 20:15:55 +00:00

missing: add syscall wrappers for new mount API

This commit is contained in:
Lennart Poettering 2021-04-27 14:16:06 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 9899580a58
commit 84e8edec30
2 changed files with 101 additions and 0 deletions

View File

@ -480,11 +480,14 @@ conf.set('SIZEOF_RLIM_T', cc.sizeof('rlim_t', prefix : '#include <sys/resource.h
decl_headers = '''
#include <uchar.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <linux/fs.h>
'''
foreach decl : ['char16_t',
'char32_t',
'struct mount_attr',
'struct statx',
]
@ -555,6 +558,9 @@ foreach ident : [
['execveat', '''#include <unistd.h>'''],
['close_range', '''#include <unistd.h>'''],
['epoll_pwait2', '''#include <sys/epoll.h>'''],
['mount_setattr', '''#include <sys/mount.h>'''],
['move_mount', '''#include <sys/mount.h>'''],
['open_tree', '''#include <sys/mount.h>'''],
]
have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')

View File

@ -425,3 +425,98 @@ static inline int missing_epoll_pwait2(
# define epoll_pwait2 missing_epoll_pwait2
#endif
/* ======================================================================= */
#if !HAVE_MOUNT_SETATTR
#if !HAVE_STRUCT_MOUNT_ATTR
struct mount_attr {
uint64_t attr_set;
uint64_t attr_clr;
uint64_t propagation;
uint64_t userns_fd;
};
#else
struct mount_attr;
#endif
#ifndef MOUNT_ATTR_IDMAP
#define MOUNT_ATTR_IDMAP 0x00100000
#endif
#ifndef AT_RECURSIVE
#define AT_RECURSIVE 0x8000
#endif
static inline int missing_mount_setattr(
int dfd,
const char *path,
unsigned flags,
struct mount_attr *attr,
size_t size) {
# if defined __NR_mount_setattr && __NR_mount_setattr >= 0
return syscall(__NR_mount_setattr, dfd, path, flags, attr, size);
# else
errno = ENOSYS;
return -1;
# endif
}
# define mount_setattr missing_mount_setattr
#endif
/* ======================================================================= */
#if !HAVE_OPEN_TREE
#ifndef OPEN_TREE_CLONE
#define OPEN_TREE_CLONE 1
#endif
#ifndef OPEN_TREE_CLOEXEC
#define OPEN_TREE_CLOEXEC O_CLOEXEC
#endif
static inline int missing_open_tree(
int dfd,
const char *filename,
unsigned flags) {
# if defined __NR_open_tree && __NR_open_tree >= 0
return syscall(__NR_open_tree, dfd, filename, flags);
# else
errno = ENOSYS;
return -1;
# endif
}
# define open_tree missing_open_tree
#endif
/* ======================================================================= */
#if !HAVE_MOVE_MOUNT
#ifndef MOVE_MOUNT_F_EMPTY_PATH
#define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
#endif
static inline int missing_move_mount(
int from_dfd,
const char *from_pathname,
int to_dfd,
const char *to_pathname,
unsigned flags) {
# if defined __NR_move_mount && __NR_move_mount >= 0
return syscall(__NR_move_mount, from_dfd, from_pathname, to_dfd, to_pathname, flags);
# else
errno = ENOSYS;
return -1;
# endif
}
# define move_mount missing_move_mount
#endif