]> git.ipfire.org Git - thirdparty/util-linux.git/blob - include/mount-api-utils.h
build-sys: add --disable-libmount-mountfd-support
[thirdparty/util-linux.git] / include / mount-api-utils.h
1 #ifndef UTIL_LINUX_MOUNT_API_UTILS
2 #define UTIL_LINUX_MOUNT_API_UTILS
3
4 #ifdef HAVE_MOUNTFD_API
5
6 #include <sys/syscall.h>
7 #include <linux/mount.h>
8
9 /* Accepted by both open_tree() and mount_setattr(). */
10 #ifndef AT_RECURSIVE
11 # define AT_RECURSIVE 0x8000
12 #endif
13
14 #ifndef OPEN_TREE_CLONE
15 # define OPEN_TREE_CLONE 1
16 #endif
17
18 #ifndef OPEN_TREE_CLOEXEC
19 # define OPEN_TREE_CLOEXEC O_CLOEXEC
20 #endif
21
22 #if !defined(HAVE_OPEN_TREE) && defined(SYS_open_tree)
23 static inline int open_tree(int dfd, const char *filename, unsigned int flags)
24 {
25 return syscall(SYS_open_tree, dfd, filename, flags);
26 }
27 #endif
28
29 #ifndef MOVE_MOUNT_F_SYMLINKS
30 # define MOVE_MOUNT_F_SYMLINKS 0x00000001 /* Follow symlinks on from path */
31 #endif
32
33 #ifndef MOVE_MOUNT_F_AUTOMOUNTS
34 # define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
35 #endif
36
37 #ifndef MOVE_MOUNT_F_EMPTY_PATH
38 # define MOVE_MOUNT_F_EMPTY_PATH 0x00000004 /* Empty from path permitted */
39 #endif
40
41 #ifndef MOVE_MOUNT_T_SYMLINKS
42 # define MOVE_MOUNT_T_SYMLINKS 0x00000010 /* Follow symlinks on to path */
43 #endif
44
45 #ifndef MOVE_MOUNT_T_AUTOMOUNTS
46 # define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */
47 #endif
48
49 #ifndef MOVE_MOUNT_T_EMPTY_PATH
50 # define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
51 #endif
52
53 #ifndef MOVE_MOUNT__MASK
54 # define MOVE_MOUNT__MASK 0x00000077
55 #endif
56
57 #if !defined(HAVE_MOVE_MOUNT) && defined(SYS_move_mount)
58 static inline int move_mount(int from_dfd, const char *from_pathname, int to_dfd,
59 const char *to_pathname, unsigned int flags)
60 {
61 return syscall(SYS_move_mount, from_dfd, from_pathname, to_dfd,
62 to_pathname, flags);
63 }
64 #endif
65
66 #ifndef MOUNT_ATTR_RDONLY
67 # define MOUNT_ATTR_RDONLY 0x00000001
68 #endif
69
70 #ifndef MOUNT_ATTR_NOSUID
71 # define MOUNT_ATTR_NOSUID 0x00000002
72 #endif
73
74 #ifndef MOUNT_ATTR_NOEXEC
75 # define MOUNT_ATTR_NOEXEC 0x00000008
76 #endif
77
78 #ifndef MOUNT_ATTR__ATIME
79 # define MOUNT_ATTR__ATIME 0x00000070
80 #endif
81
82 #ifndef MOUNT_ATTR_RELATIME
83 # define MOUNT_ATTR_RELATIME 0x00000000
84 #endif
85
86 #ifndef MOUNT_ATTR_NOATIME
87 # define MOUNT_ATTR_NOATIME 0x00000010
88 #endif
89
90 #ifndef MOUNT_ATTR_STRICTATIME
91 # define MOUNT_ATTR_STRICTATIME 0x00000020
92 #endif
93
94 #ifndef MOUNT_ATTR_NODIRATIME
95 # define MOUNT_ATTR_NODIRATIME 0x00000080
96 #endif
97
98 #ifndef MOUNT_ATTR_IDMAP
99 # define MOUNT_ATTR_IDMAP 0x00100000
100 #endif
101
102 #ifndef MOUNT_ATTR_NOSYMFOLLOW
103 # define MOUNT_ATTR_NOSYMFOLLOW 0x00200000
104 #endif
105
106 #ifndef HAVE_STRUCT_MOUNT_ATTR
107 # include <inttypes.h>
108 struct mount_attr {
109 uint64_t attr_set;
110 uint64_t attr_clr;
111 uint64_t propagation;
112 uint64_t userns_fd;
113 };
114 #endif
115
116 #if !defined(HAVE_MOUNT_SETATTR) && defined(SYS_mount_setattr)
117 static inline int mount_setattr(int dfd, const char *path, unsigned int flags,
118 struct mount_attr *attr, size_t size)
119 {
120 return syscall(SYS_mount_setattr, dfd, path, flags, attr, size);
121 }
122 #endif
123
124 #ifndef HAVE_ENUM_FSCONFIG_COMMAND
125 enum fsconfig_command {
126 FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
127 FSCONFIG_SET_STRING = 1, /* Set parameter, supplying a string value */
128 FSCONFIG_SET_BINARY = 2, /* Set parameter, supplying a binary blob value */
129 FSCONFIG_SET_PATH = 3, /* Set parameter, supplying an object by path */
130 FSCONFIG_SET_PATH_EMPTY = 4, /* Set parameter, supplying an object by (empty) path */
131 FSCONFIG_SET_FD = 5, /* Set parameter, supplying an object by fd */
132 FSCONFIG_CMD_CREATE = 6, /* Invoke superblock creation */
133 FSCONFIG_CMD_RECONFIGURE = 7, /* Invoke superblock reconfiguration */
134 };
135 #endif
136
137 #if !defined(HAVE_FSCONFIG) && defined(SYS_fsconfig)
138 static inline int fsconfig(int fd, unsigned int cmd, const char *key,
139 const void *value, int aux)
140 {
141 return syscall(SYS_fsconfig, fd, cmd, key, value, aux);
142 }
143 #endif
144
145 #ifndef FSOPEN_CLOEXEC
146 # define FSOPEN_CLOEXEC 0x00000001
147 #endif
148
149 #if !defined(HAVE_FSOPEN) && defined(SYS_fsopen)
150 static inline int fsopen(const char *fsname, unsigned int flags)
151 {
152 return syscall(SYS_fsopen, fsname, flags);
153 }
154 #endif
155
156 #ifndef FSMOUNT_CLOEXEC
157 # define FSMOUNT_CLOEXEC 0x00000001
158 #endif
159
160 #if !defined(HAVE_FSMOUNT) && defined(SYS_fsmount)
161 static inline int fsmount(int fd, unsigned int flags, unsigned int mount_attrs)
162 {
163 return syscall(SYS_fsmount, fd, flags, mount_attrs);
164 }
165 #endif
166
167 #ifndef FSPICK_CLOEXEC
168 # define FSPICK_CLOEXEC 0x00000001
169 #endif
170
171 #ifndef FSPICK_SYMLINK_NOFOLLOW
172 # define FSPICK_SYMLINK_NOFOLLOW 0x00000002
173 #endif
174
175 #ifndef FSPICK_NO_AUTOMOUNT
176 # define FSPICK_NO_AUTOMOUNT 0x00000004
177 #endif
178
179 #ifdef FSPICK_EMPTY_PATH
180 # define FSPICK_EMPTY_PATH 0x00000008
181 #endif
182
183 #if !defined(HAVE_FSPICK) && defined(SYS_fspick)
184 static inline int fspick(int dfd, const char *pathname, unsigned int flags)
185 {
186 return syscall(SYS_fspick, dfd, pathname, flags);
187 }
188 #endif
189
190 #endif /* HAVE_MOUNTFD_API */
191 #endif /* UTIL_LINUX_MOUNT_API_UTILS */
192