]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - include/mount-api-utils.h
2 * No copyright is claimed. This code is in the public domain; do with
5 #ifndef UTIL_LINUX_MOUNT_API_UTILS
6 #define UTIL_LINUX_MOUNT_API_UTILS
8 #if defined(HAVE_MOUNTFD_API) && defined(HAVE_LINUX_MOUNT_H)
10 #include <sys/syscall.h>
11 #include <linux/mount.h>
13 /* Accepted by both open_tree() and mount_setattr(). */
15 # define AT_RECURSIVE 0x8000
18 #ifndef OPEN_TREE_CLONE
19 # define OPEN_TREE_CLONE 1
22 #ifndef OPEN_TREE_CLOEXEC
23 # define OPEN_TREE_CLOEXEC O_CLOEXEC
26 #if !defined(HAVE_OPEN_TREE) && defined(SYS_open_tree)
27 static inline int open_tree(int dfd
, const char *filename
, unsigned int flags
)
29 return syscall(SYS_open_tree
, dfd
, filename
, flags
);
33 #ifndef MOVE_MOUNT_F_SYMLINKS
34 # define MOVE_MOUNT_F_SYMLINKS 0x00000001 /* Follow symlinks on from path */
37 #ifndef MOVE_MOUNT_F_AUTOMOUNTS
38 # define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
41 #ifndef MOVE_MOUNT_F_EMPTY_PATH
42 # define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
45 #ifndef MOVE_MOUNT_T_SYMLINKS
46 # define MOVE_MOUNT_T_SYMLINKS 0x00000010 /* Follow symlinks on to path */
49 #ifndef MOVE_MOUNT_T_AUTOMOUNTS
50 # define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */
53 #ifndef MOVE_MOUNT_T_EMPTY_PATH
54 # define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
57 #ifndef MOVE_MOUNT_SET_GROUP
58 # define MOVE_MOUNT_SET_GROUP 0x00000100 /* Set sharing group instead */
61 #ifndef MOVE_MOUNT__MASK
62 # define MOVE_MOUNT__MASK 0x00000077
65 #if !defined(HAVE_MOVE_MOUNT) && defined(SYS_move_mount)
66 static inline int move_mount(int from_dfd
, const char *from_pathname
, int to_dfd
,
67 const char *to_pathname
, unsigned int flags
)
69 return syscall(SYS_move_mount
, from_dfd
, from_pathname
, to_dfd
,
74 #ifndef MOUNT_ATTR_RDONLY
75 # define MOUNT_ATTR_RDONLY 0x00000001
78 #ifndef MOUNT_ATTR_NOSUID
79 # define MOUNT_ATTR_NOSUID 0x00000002
82 #ifndef MOUNT_ATTR_NODEV
83 # define MOUNT_ATTR_NODEV 0x00000004
86 #ifndef MOUNT_ATTR_NOEXEC
87 # define MOUNT_ATTR_NOEXEC 0x00000008
90 #ifndef MOUNT_ATTR__ATIME
91 # define MOUNT_ATTR__ATIME 0x00000070
94 #ifndef MOUNT_ATTR_RELATIME
95 # define MOUNT_ATTR_RELATIME 0x00000000
98 #ifndef MOUNT_ATTR_NOATIME
99 # define MOUNT_ATTR_NOATIME 0x00000010
102 #ifndef MOUNT_ATTR_STRICTATIME
103 # define MOUNT_ATTR_STRICTATIME 0x00000020
106 #ifndef MOUNT_ATTR_NODIRATIME
107 # define MOUNT_ATTR_NODIRATIME 0x00000080
110 #ifndef MOUNT_ATTR_IDMAP
111 # define MOUNT_ATTR_IDMAP 0x00100000
114 #ifndef MOUNT_ATTR_NOSYMFOLLOW
115 # define MOUNT_ATTR_NOSYMFOLLOW 0x00200000
118 #ifndef HAVE_STRUCT_MOUNT_ATTR
119 # ifndef MOUNT_ATTR_SIZE_VER0 /* For case mount.h comes from a place invisible for autotools/meson */
120 # include <inttypes.h>
124 uint64_t propagation
;
130 #if !defined(HAVE_MOUNT_SETATTR) && defined(SYS_mount_setattr)
131 static inline int mount_setattr(int dfd
, const char *path
, unsigned int flags
,
132 struct mount_attr
*attr
, size_t size
)
134 return syscall(SYS_mount_setattr
, dfd
, path
, flags
, attr
, size
);
138 #ifndef HAVE_ENUM_FSCONFIG_COMMAND
139 # ifndef FSOPEN_CLOEXEC /* For case mount.h comes from a place invisible for autotools/meson */
140 enum fsconfig_command
{
141 FSCONFIG_SET_FLAG
= 0, /* Set parameter, supplying no value */
142 FSCONFIG_SET_STRING
= 1, /* Set parameter, supplying a string value */
143 FSCONFIG_SET_BINARY
= 2, /* Set parameter, supplying a binary blob value */
144 FSCONFIG_SET_PATH
= 3, /* Set parameter, supplying an object by path */
145 FSCONFIG_SET_PATH_EMPTY
= 4, /* Set parameter, supplying an object by (empty) path */
146 FSCONFIG_SET_FD
= 5, /* Set parameter, supplying an object by fd */
147 FSCONFIG_CMD_CREATE
= 6, /* Invoke superblock creation */
148 FSCONFIG_CMD_RECONFIGURE
= 7, /* Invoke superblock reconfiguration */
153 #if !defined(HAVE_FSCONFIG) && defined(SYS_fsconfig)
154 static inline int fsconfig(int fd
, unsigned int cmd
, const char *key
,
155 const void *value
, int aux
)
157 return syscall(SYS_fsconfig
, fd
, cmd
, key
, value
, aux
);
161 #ifndef FSOPEN_CLOEXEC
162 # define FSOPEN_CLOEXEC 0x00000001
165 #if !defined(HAVE_FSOPEN) && defined(SYS_fsopen)
166 static inline int fsopen(const char *fsname
, unsigned int flags
)
168 return syscall(SYS_fsopen
, fsname
, flags
);
172 #ifndef FSMOUNT_CLOEXEC
173 # define FSMOUNT_CLOEXEC 0x00000001
176 #if !defined(HAVE_FSMOUNT) && defined(SYS_fsmount)
177 static inline int fsmount(int fd
, unsigned int flags
, unsigned int mount_attrs
)
179 return syscall(SYS_fsmount
, fd
, flags
, mount_attrs
);
183 #ifndef FSPICK_CLOEXEC
184 # define FSPICK_CLOEXEC 0x00000001
187 #ifndef FSPICK_SYMLINK_NOFOLLOW
188 # define FSPICK_SYMLINK_NOFOLLOW 0x00000002
191 #ifndef FSPICK_NO_AUTOMOUNT
192 # define FSPICK_NO_AUTOMOUNT 0x00000004
195 #ifdef FSPICK_EMPTY_PATH
196 # define FSPICK_EMPTY_PATH 0x00000008
199 #if !defined(HAVE_FSPICK) && defined(SYS_fspick)
200 static inline int fspick(int dfd
, const char *pathname
, unsigned int flags
)
202 return syscall(SYS_fspick
, dfd
, pathname
, flags
);
206 #endif /* HAVE_MOUNTFD_API && HAVE_LINUX_MOUNT_H */
207 #endif /* UTIL_LINUX_MOUNT_API_UTILS */