]>
Commit | Line | Data |
---|---|---|
2c37ca7c | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
f1cde479 | 2 | /* |
2c37ca7c | 3 | * libmount.h - libmount API |
f1cde479 | 4 | * |
2c37ca7c KZ |
5 | * This file is part of libmount from util-linux project. |
6 | * | |
7 | * Copyright (C) 2008-2018 Karel Zak <kzak@redhat.com> | |
f1cde479 KZ |
8 | * |
9 | * This library is free software; you can redistribute it and/or | |
10 | * modify it under the terms of the GNU Lesser General Public | |
11 | * License as published by the Free Software Foundation; either | |
12 | * version 2.1 of the License, or (at your option) any later version. | |
13 | * | |
14 | * This library is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | * Lesser General Public License for more details. | |
18 | * | |
7cebf0bb SK |
19 | * You should have received a copy of the GNU General Public License along |
20 | * with this program; if not, write to the Free Software Foundation, Inc., | |
21 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
f1cde479 KZ |
22 | */ |
23 | ||
24 | #ifndef _LIBMOUNT_MOUNT_H | |
25 | #define _LIBMOUNT_MOUNT_H | |
26 | ||
27 | #ifdef __cplusplus | |
28 | extern "C" { | |
29 | #endif | |
30 | ||
078edb2d | 31 | #include <stdio.h> |
8b95253f | 32 | #include <mntent.h> |
b98302b4 | 33 | #include <sys/types.h> |
061d1a51 KZ |
34 | |
35 | /* Make sure libc MS_* definitions are used by default. Note that MS_* flags | |
36 | * may be already defined by linux/fs.h or another file -- in this case we | |
37 | * don't want to include sys/mount.h at all to avoid collisions. | |
38 | */ | |
c0bdff99 | 39 | #if defined(__linux__) && !defined(MS_RDONLY) |
061d1a51 KZ |
40 | # include <sys/mount.h> |
41 | #endif | |
078edb2d | 42 | |
f1cde479 | 43 | #define LIBMOUNT_VERSION "@LIBMOUNT_VERSION@" |
10e1d2e5 SH |
44 | #define LIBMOUNT_MAJOR_VERSION @LIBMOUNT_MAJOR_VERSION@ |
45 | #define LIBMOUNT_MINOR_VERSION @LIBMOUNT_MINOR_VERSION@ | |
46 | #define LIBMOUNT_PATCH_VERSION @LIBMOUNT_PATCH_VERSION@ | |
f1cde479 | 47 | |
7755ca95 | 48 | /** |
68164f6c | 49 | * libmnt_cache: |
7755ca95 KZ |
50 | * |
51 | * Stores canonicalized paths and evaluated tags | |
52 | */ | |
68164f6c | 53 | struct libmnt_cache; |
7755ca95 | 54 | |
27c6d415 | 55 | /** |
68164f6c | 56 | * libmnt_lock: |
27c6d415 | 57 | * |
d58b3157 | 58 | * Stores information about the locked file (e.g. /etc/mtab) |
27c6d415 | 59 | */ |
68164f6c | 60 | struct libmnt_lock; |
27c6d415 | 61 | |
efab4b61 | 62 | /** |
68164f6c | 63 | * libmnt_iter: |
efab4b61 KZ |
64 | * |
65 | * Generic iterator (stores state about lists) | |
66 | */ | |
68164f6c | 67 | struct libmnt_iter; |
efab4b61 | 68 | |
078edb2d | 69 | /** |
68164f6c | 70 | * libmnt_optmap: |
3df1a79a KZ |
71 | * @name: option name[=type] where type is printf-like type specifier") |
72 | * @id: option ID or MS_* flags (e.g MS_RDONLY) | |
73 | * @mask: MNT_{NOMTAB,INVERT,...} mask | |
078edb2d KZ |
74 | * |
75 | * Mount options description (map) | |
078edb2d | 76 | */ |
68164f6c | 77 | struct libmnt_optmap |
078edb2d | 78 | { |
3df1a79a KZ |
79 | const char *name; |
80 | int id; | |
81 | int mask; | |
078edb2d KZ |
82 | }; |
83 | ||
84 | /* | |
85 | * mount options map masks | |
86 | */ | |
66b8b8cd KZ |
87 | #define MNT_INVERT (1 << 1) /* invert the mountflag */ |
88 | #define MNT_NOMTAB (1 << 2) /* skip in the mtab option string */ | |
699abc83 | 89 | #define MNT_PREFIX (1 << 3) /* prefix used for some options (e.g. "x-foo") */ |
5810d870 | 90 | #define MNT_NOHLPS (1 << 4) /* don't add the option to mount.<type> helpers command line */ |
078edb2d | 91 | |
d115ee9b | 92 | /** |
68164f6c | 93 | * libmnt_fs: |
d115ee9b KZ |
94 | * |
95 | * Parsed fstab/mtab/mountinfo entry | |
96 | */ | |
68164f6c | 97 | struct libmnt_fs; |
d115ee9b | 98 | |
6bd8b7a7 | 99 | /** |
68164f6c | 100 | * libmnt_table: |
6bd8b7a7 | 101 | * |
68164f6c | 102 | * List of struct libmnt_fs entries (parsed fstab/mtab/mountinfo) |
6bd8b7a7 | 103 | */ |
68164f6c | 104 | struct libmnt_table; |
6bd8b7a7 | 105 | |
922d8796 | 106 | /** |
68164f6c | 107 | * libmnt_update |
922d8796 | 108 | * |
a362ae60 | 109 | * /etc/mtab or utab update description |
922d8796 | 110 | */ |
68164f6c | 111 | struct libmnt_update; |
922d8796 | 112 | |
8fa67157 | 113 | /** |
68164f6c | 114 | * libmnt_context |
8fa67157 KZ |
115 | * |
116 | * Mount/umount status | |
117 | */ | |
68164f6c | 118 | struct libmnt_context; |
8fa67157 | 119 | |
372112e9 KZ |
120 | /** |
121 | * libmnt_monitor | |
122 | * | |
123 | * Mount tables monitor | |
124 | */ | |
125 | struct libmnt_monitor; | |
126 | ||
e6ecd606 KZ |
127 | /** |
128 | * libmnt_tabdiff: | |
129 | * | |
130 | * Stores mountinfo state | |
131 | */ | |
132 | struct libmnt_tabdiff; | |
133 | ||
4917d842 VD |
134 | /** |
135 | * libmnt_ns: | |
136 | * | |
137 | * Describes mount namespace | |
138 | */ | |
139 | struct libmnt_ns; | |
140 | ||
8378ede9 KZ |
141 | /* |
142 | * Actions | |
143 | */ | |
922d8796 KZ |
144 | enum { |
145 | MNT_ACT_MOUNT = 1, | |
146 | MNT_ACT_UMOUNT | |
147 | }; | |
148 | ||
47dea49b KZ |
149 | /* |
150 | * Errors -- by default libmount returns -errno for generic errors (ENOMEM, | |
151 | * EINVAL, ...) and for mount(2) errors, but for some specific operations it | |
152 | * returns private error codes. Note that maximum system errno value should be | |
153 | * 4095 on UNIXes. | |
154 | * | |
155 | * See also mnt_context_get_syscall_errno() and mnt_context_get_helper_status(). | |
156 | */ | |
a3bb7e65 KZ |
157 | /** |
158 | * MNT_ERR_NOFSTAB: | |
159 | * | |
160 | * not found required entry in fstab | |
161 | */ | |
162 | #define MNT_ERR_NOFSTAB 5000 | |
163 | /** | |
164 | * MNT_ERR_NOFSTYPE: | |
165 | * | |
166 | * failed to detect filesystem type | |
167 | */ | |
168 | #define MNT_ERR_NOFSTYPE 5001 | |
169 | /** | |
170 | * MNT_ERR_NOSOURCE: | |
171 | * | |
172 | * required mount source undefined | |
173 | */ | |
174 | #define MNT_ERR_NOSOURCE 5002 | |
175 | /** | |
176 | * MNT_ERR_LOOPDEV: | |
177 | * | |
178 | * loopdev setup failed, errno set by libc | |
179 | */ | |
7e6b7035 | 180 | #define MNT_ERR_LOOPDEV 5003 |
a3bb7e65 KZ |
181 | /** |
182 | * MNT_ERR_MOUNTOPT: | |
183 | * | |
184 | * failed to parse/use userspace mount options | |
185 | */ | |
186 | #define MNT_ERR_MOUNTOPT 5004 | |
187 | /** | |
188 | * MNT_ERR_APPLYFLAGS: | |
189 | * | |
190 | * failed to apply MS_PROPAGATION flags | |
191 | */ | |
192 | #define MNT_ERR_APPLYFLAGS 5005 | |
193 | /** | |
194 | * MNT_ERR_AMBIFS: | |
195 | * | |
196 | * libblkid detected more filesystems on the device | |
197 | */ | |
198 | #define MNT_ERR_AMBIFS 5006 | |
7e6b7035 SB |
199 | /** |
200 | * MNT_ERR_LOOPOVERLAP: | |
201 | * | |
202 | * detected overlapping loop device that cannot be re-used | |
203 | */ | |
204 | #define MNT_ERR_LOOPOVERLAP 5007 | |
d369dc42 KZ |
205 | /** |
206 | * MNT_ERR_LOCK: | |
207 | * | |
208 | * failed to lock mtab/utab or so. | |
209 | */ | |
210 | #define MNT_ERR_LOCK 5008 | |
8342e584 VD |
211 | /** |
212 | * MNT_ERR_NAMESPACE: | |
213 | * | |
214 | * failed to switch namespace | |
215 | */ | |
216 | #define MNT_ERR_NAMESPACE 5009 | |
47dea49b | 217 | |
ea848180 KZ |
218 | |
219 | /* | |
220 | * Overall return codes -- based on mount(8) and umount(8) return codes. | |
221 | * See mnt_context_get_excode() for more details. | |
222 | */ | |
223 | ||
224 | /** | |
225 | * MNT_EX_SUCCESS: | |
226 | * | |
227 | * [u]mount(8) exit code: no errors | |
228 | */ | |
229 | #define MNT_EX_SUCCESS 0 | |
230 | ||
231 | /** | |
232 | * MNT_EX_USAGE: | |
233 | * | |
234 | * [u]mount(8) exit code: incorrect invocation or permission | |
235 | */ | |
236 | #define MNT_EX_USAGE 1 | |
237 | ||
238 | /** | |
239 | * MNT_EX_SYSERR: | |
240 | * | |
241 | * [u]mount(8) exit code: out of memory, cannot fork, ... | |
242 | */ | |
243 | ||
244 | #define MNT_EX_SYSERR 2 | |
245 | ||
246 | /** | |
247 | * MNT_EX_SOFTWARE: | |
248 | * | |
249 | * [u]mount(8) exit code: internal mount bug or wrong version | |
250 | */ | |
251 | #define MNT_EX_SOFTWARE 4 | |
252 | ||
253 | /** | |
254 | * MNT_EX_USER: | |
255 | * | |
256 | * [u]mount(8) exit code: user interrupt | |
257 | */ | |
258 | #define MNT_EX_USER 8 | |
259 | ||
260 | /** | |
261 | * MNT_EX_FILEIO: | |
262 | * | |
d369dc42 | 263 | * [u]mount(8) exit code: problems writing, locking, ... mtab/utab |
ea848180 KZ |
264 | */ |
265 | #define MNT_EX_FILEIO 16 | |
266 | ||
267 | /** | |
268 | * MNT_EX_FAIL: | |
269 | * | |
270 | * [u]mount(8) exit code: mount failure | |
271 | */ | |
272 | #define MNT_EX_FAIL 32 | |
273 | ||
274 | /** | |
275 | * MNT_EX_SOMEOK: | |
276 | * | |
277 | * [u]mount(8) exit code: some mount succeeded; usually when executed with | |
278 | * --all options. Never returned by libmount. | |
279 | */ | |
280 | #define MNT_EX_SOMEOK 64 | |
281 | ||
282 | ||
283 | ||
a6397785 OO |
284 | #ifndef __GNUC_PREREQ |
285 | # if defined __GNUC__ && defined __GNUC_MINOR__ | |
286 | # define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) | |
287 | # else | |
288 | # define __GNUC_PREREQ(maj, min) 0 | |
289 | # endif | |
290 | #endif | |
291 | ||
292 | #ifndef __ul_attribute__ | |
293 | # if __GNUC_PREREQ (3, 4) | |
294 | # define __ul_attribute__(_a_) __attribute__(_a_) | |
295 | # else | |
296 | # define __ul_attribute__(_a_) | |
297 | # endif | |
298 | #endif | |
299 | ||
300 | ||
afa03b9d KZ |
301 | /* init.c */ |
302 | extern void mnt_init_debug(int mask); | |
d115ee9b | 303 | |
f4ab4ae8 | 304 | /* version.c */ |
4569bbea | 305 | extern int mnt_parse_version_string(const char *ver_string); |
f4ab4ae8 | 306 | extern int mnt_get_library_version(const char **ver_string); |
ba2bdf41 | 307 | extern int mnt_get_library_features(const char ***features); |
f4ab4ae8 | 308 | |
69b7e41e | 309 | /* utils.c */ |
a6397785 | 310 | extern char *mnt_mangle(const char *str) |
a6397785 OO |
311 | __ul_attribute__((warn_unused_result)); |
312 | extern char *mnt_unmangle(const char *str) | |
a6397785 | 313 | __ul_attribute__((warn_unused_result)); |
ba2bdf41 | 314 | |
a53cc4e0 | 315 | extern int mnt_tag_is_valid(const char *tag); |
4569bbea KZ |
316 | extern int mnt_fstype_is_netfs(const char *type); |
317 | extern int mnt_fstype_is_pseudofs(const char *type); | |
ba2bdf41 | 318 | |
a6397785 OO |
319 | extern int mnt_match_fstype(const char *type, const char *pattern) |
320 | __ul_attribute__((warn_unused_result)); | |
321 | extern int mnt_match_options(const char *optstr, const char *pattern) | |
322 | __ul_attribute__((warn_unused_result)); | |
a3bb7e65 KZ |
323 | extern const char *mnt_get_fstab_path(void); |
324 | extern const char *mnt_get_swaps_path(void); | |
325 | extern const char *mnt_get_mtab_path(void); | |
1d0cd73f | 326 | extern int mnt_has_regular_mtab(const char **mtab, int *writable); |
a6397785 | 327 | extern char *mnt_get_mountpoint(const char *path) |
4569bbea | 328 | __ul_attribute__((warn_unused_result)); |
1dae161c KZ |
329 | extern int mnt_guess_system_root(dev_t devno, struct libmnt_cache *cache, char **path) |
330 | __ul_attribute__((nonnull(3))); | |
69b7e41e | 331 | |
7755ca95 | 332 | /* cache.c */ |
a6397785 OO |
333 | extern struct libmnt_cache *mnt_new_cache(void) |
334 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 335 | extern void mnt_free_cache(struct libmnt_cache *cache); |
a6397785 | 336 | |
0105691d KZ |
337 | extern void mnt_ref_cache(struct libmnt_cache *cache); |
338 | extern void mnt_unref_cache(struct libmnt_cache *cache); | |
339 | ||
0382ba32 ER |
340 | extern int mnt_cache_set_targets(struct libmnt_cache *cache, |
341 | struct libmnt_table *mtab); | |
ba2bdf41 KZ |
342 | extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname); |
343 | ||
68164f6c KZ |
344 | extern int mnt_cache_device_has_tag(struct libmnt_cache *cache, |
345 | const char *devname, | |
346 | const char *token, | |
4569bbea | 347 | const char *value); |
ba7232a1 | 348 | |
68164f6c | 349 | extern char *mnt_cache_find_tag_value(struct libmnt_cache *cache, |
a3bb7e65 | 350 | const char *devname, const char *token); |
ba7232a1 | 351 | |
68164f6c | 352 | extern char *mnt_get_fstype(const char *devname, int *ambi, |
a6397785 | 353 | struct libmnt_cache *cache) |
a6397785 OO |
354 | __ul_attribute__((warn_unused_result)); |
355 | extern char *mnt_resolve_path(const char *path, struct libmnt_cache *cache) | |
a6397785 | 356 | __ul_attribute__((warn_unused_result)); |
0382ba32 ER |
357 | extern char *mnt_resolve_target(const char *path, struct libmnt_cache *cache) |
358 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 359 | extern char *mnt_resolve_tag(const char *token, const char *value, |
a6397785 | 360 | struct libmnt_cache *cache) |
a6397785 OO |
361 | __ul_attribute__((warn_unused_result)); |
362 | extern char *mnt_resolve_spec(const char *spec, struct libmnt_cache *cache) | |
a6397785 | 363 | __ul_attribute__((warn_unused_result)); |
a6397785 | 364 | extern char *mnt_pretty_path(const char *path, struct libmnt_cache *cache) |
a6397785 | 365 | __ul_attribute__((warn_unused_result)); |
2576b4e7 | 366 | |
9e272c68 KZ |
367 | /* optstr.c */ |
368 | extern int mnt_optstr_next_option(char **optstr, char **name, size_t *namesz, | |
4569bbea | 369 | char **value, size_t *valuesz); |
9e272c68 | 370 | extern int mnt_optstr_append_option(char **optstr, const char *name, |
4569bbea | 371 | const char *value); |
e87c03f4 | 372 | extern int mnt_optstr_prepend_option(char **optstr, const char *name, |
4569bbea | 373 | const char *value); |
ba2bdf41 | 374 | |
9f7472b0 | 375 | extern int mnt_optstr_get_option(const char *optstr, const char *name, |
ba2bdf41 | 376 | char **value, size_t *valsz); |
9e272c68 | 377 | extern int mnt_optstr_set_option(char **optstr, const char *name, |
4569bbea KZ |
378 | const char *value); |
379 | extern int mnt_optstr_remove_option(char **optstr, const char *name); | |
380 | extern int mnt_optstr_deduplicate_option(char **optstr, const char *name); | |
9e272c68 | 381 | |
f309b8a7 KZ |
382 | extern int mnt_split_optstr(const char *optstr, |
383 | char **user, char **vfs, char **fs, | |
ba2bdf41 | 384 | int ignore_user, int ignore_vfs); |
3661b841 | 385 | |
f84fa6f7 | 386 | extern int mnt_optstr_get_options(const char *optstr, char **subset, |
ba2bdf41 | 387 | const struct libmnt_optmap *map, int ignore); |
f84fa6f7 | 388 | |
66b8b8cd | 389 | extern int mnt_optstr_get_flags(const char *optstr, unsigned long *flags, |
ba2bdf41 | 390 | const struct libmnt_optmap *map); |
922d8796 | 391 | |
ba2bdf41 KZ |
392 | extern int mnt_optstr_apply_flags(char **optstr, unsigned long flags, |
393 | const struct libmnt_optmap *map); | |
6870636c | 394 | |
efab4b61 KZ |
395 | /* iter.c */ |
396 | enum { | |
397 | ||
398 | MNT_ITER_FORWARD = 0, | |
399 | MNT_ITER_BACKWARD | |
400 | }; | |
a6397785 OO |
401 | extern struct libmnt_iter *mnt_new_iter(int direction) |
402 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 403 | extern void mnt_free_iter(struct libmnt_iter *itr); |
a6397785 OO |
404 | |
405 | extern void mnt_reset_iter(struct libmnt_iter *itr, int direction) | |
406 | __ul_attribute__((nonnull)); | |
407 | extern int mnt_iter_get_direction(struct libmnt_iter *itr) | |
a3bb7e65 | 408 | __ul_attribute__((nonnull)); |
efab4b61 | 409 | |
078edb2d KZ |
410 | /* optmap.c */ |
411 | enum { | |
412 | MNT_LINUX_MAP = 1, | |
413 | MNT_USERSPACE_MAP | |
414 | }; | |
a3bb7e65 | 415 | extern const struct libmnt_optmap *mnt_get_builtin_optmap(int id); |
078edb2d | 416 | |
27c6d415 | 417 | /* lock.c */ |
a6397785 | 418 | extern struct libmnt_lock *mnt_new_lock(const char *datafile, pid_t id) |
4569bbea | 419 | __ul_attribute__((warn_unused_result)); |
68164f6c | 420 | extern void mnt_free_lock(struct libmnt_lock *ml); |
a6397785 | 421 | |
4569bbea | 422 | extern void mnt_unlock_file(struct libmnt_lock *ml); |
ba2bdf41 KZ |
423 | extern int mnt_lock_file(struct libmnt_lock *ml); |
424 | extern int mnt_lock_block_signals(struct libmnt_lock *ml, int enable); | |
27c6d415 | 425 | |
d115ee9b | 426 | /* fs.c */ |
a6397785 OO |
427 | extern struct libmnt_fs *mnt_new_fs(void) |
428 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 429 | extern void mnt_free_fs(struct libmnt_fs *fs); |
26d0c0ae KZ |
430 | extern void mnt_ref_fs(struct libmnt_fs *fs); |
431 | extern void mnt_unref_fs(struct libmnt_fs *fs); | |
a6397785 | 432 | |
4569bbea | 433 | extern void mnt_reset_fs(struct libmnt_fs *fs); |
309139c7 | 434 | extern struct libmnt_fs *mnt_copy_fs(struct libmnt_fs *dest, |
a6397785 | 435 | const struct libmnt_fs *src) |
52a285bf | 436 | __ul_attribute__((warn_unused_result)); |
4569bbea | 437 | extern void *mnt_fs_get_userdata(struct libmnt_fs *fs); |
ba2bdf41 | 438 | extern int mnt_fs_set_userdata(struct libmnt_fs *fs, void *data); |
4569bbea | 439 | extern const char *mnt_fs_get_source(struct libmnt_fs *fs); |
ba2bdf41 | 440 | extern int mnt_fs_set_source(struct libmnt_fs *fs, const char *source); |
a3bb7e65 KZ |
441 | extern const char *mnt_fs_get_srcpath(struct libmnt_fs *fs); |
442 | ||
68164f6c | 443 | extern int mnt_fs_get_tag(struct libmnt_fs *fs, const char **name, |
4569bbea KZ |
444 | const char **value); |
445 | extern const char *mnt_fs_get_target(struct libmnt_fs *fs); | |
81b176c4 | 446 | extern int mnt_fs_set_target(struct libmnt_fs *fs, const char *tgt); |
4569bbea | 447 | extern const char *mnt_fs_get_fstype(struct libmnt_fs *fs); |
ba2bdf41 | 448 | extern int mnt_fs_set_fstype(struct libmnt_fs *fs, const char *fstype); |
a6397785 OO |
449 | |
450 | extern int mnt_fs_streq_srcpath(struct libmnt_fs *fs, const char *path) | |
a6397785 OO |
451 | __ul_attribute__((warn_unused_result)); |
452 | extern int mnt_fs_streq_target(struct libmnt_fs *fs, const char *path) | |
a6397785 OO |
453 | __ul_attribute__((warn_unused_result)); |
454 | ||
455 | extern char *mnt_fs_strdup_options(struct libmnt_fs *fs) | |
4569bbea | 456 | __ul_attribute__((warn_unused_result)); |
a6397785 | 457 | extern const char *mnt_fs_get_options(struct libmnt_fs *fs) |
4569bbea | 458 | __ul_attribute__((warn_unused_result)); |
e47a1931 | 459 | extern const char *mnt_fs_get_optional_fields(struct libmnt_fs *fs) |
4569bbea | 460 | __ul_attribute__((warn_unused_result)); |
4b9d67a2 KZ |
461 | extern int mnt_fs_get_propagation(struct libmnt_fs *fs, unsigned long *flags); |
462 | ||
ba2bdf41 KZ |
463 | extern int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr); |
464 | extern int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr); | |
465 | extern int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr); | |
68164f6c KZ |
466 | |
467 | extern int mnt_fs_get_option(struct libmnt_fs *fs, const char *name, | |
ba2bdf41 | 468 | char **value, size_t *valsz); |
a6397785 | 469 | |
4569bbea KZ |
470 | extern const char *mnt_fs_get_fs_options(struct libmnt_fs *fs); |
471 | extern const char *mnt_fs_get_vfs_options(struct libmnt_fs *fs); | |
472 | extern const char *mnt_fs_get_user_options(struct libmnt_fs *fs); | |
a6397785 | 473 | |
4569bbea | 474 | extern const char *mnt_fs_get_attributes(struct libmnt_fs *fs); |
ba2bdf41 | 475 | extern int mnt_fs_set_attributes(struct libmnt_fs *fs, const char *optstr); |
68164f6c | 476 | extern int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name, |
ba2bdf41 KZ |
477 | char **value, size_t *valsz); |
478 | extern int mnt_fs_append_attributes(struct libmnt_fs *fs, const char *optstr); | |
479 | extern int mnt_fs_prepend_attributes(struct libmnt_fs *fs, const char *optstr); | |
a6397785 | 480 | |
4569bbea | 481 | extern int mnt_fs_get_freq(struct libmnt_fs *fs); |
ba2bdf41 | 482 | extern int mnt_fs_set_freq(struct libmnt_fs *fs, int freq); |
4569bbea | 483 | extern int mnt_fs_get_passno(struct libmnt_fs *fs); |
ba2bdf41 | 484 | extern int mnt_fs_set_passno(struct libmnt_fs *fs, int passno); |
4569bbea | 485 | extern const char *mnt_fs_get_root(struct libmnt_fs *fs); |
81b176c4 | 486 | extern int mnt_fs_set_root(struct libmnt_fs *fs, const char *path); |
4569bbea | 487 | extern const char *mnt_fs_get_bindsrc(struct libmnt_fs *fs); |
ba2bdf41 | 488 | extern int mnt_fs_set_bindsrc(struct libmnt_fs *fs, const char *src); |
4569bbea KZ |
489 | extern int mnt_fs_get_id(struct libmnt_fs *fs); |
490 | extern int mnt_fs_get_parent_id(struct libmnt_fs *fs); | |
491 | extern dev_t mnt_fs_get_devno(struct libmnt_fs *fs); | |
492 | extern pid_t mnt_fs_get_tid(struct libmnt_fs *fs); | |
a6397785 | 493 | |
4569bbea KZ |
494 | extern const char *mnt_fs_get_swaptype(struct libmnt_fs *fs); |
495 | extern off_t mnt_fs_get_size(struct libmnt_fs *fs); | |
496 | extern off_t mnt_fs_get_usedsize(struct libmnt_fs *fs); | |
497 | extern int mnt_fs_get_priority(struct libmnt_fs *fs); | |
48df5980 | 498 | extern int mnt_fs_set_priority(struct libmnt_fs *fs, int prio); |
ce4dd666 | 499 | |
cb90e24e OO |
500 | extern const char *mnt_fs_get_comment(struct libmnt_fs *fs); |
501 | extern int mnt_fs_set_comment(struct libmnt_fs *fs, const char *comm); | |
502 | extern int mnt_fs_append_comment(struct libmnt_fs *fs, const char *comm); | |
503 | ||
68164f6c | 504 | extern int mnt_fs_match_target(struct libmnt_fs *fs, const char *target, |
4569bbea | 505 | struct libmnt_cache *cache); |
68164f6c | 506 | extern int mnt_fs_match_source(struct libmnt_fs *fs, const char *source, |
4569bbea KZ |
507 | struct libmnt_cache *cache); |
508 | extern int mnt_fs_match_fstype(struct libmnt_fs *fs, const char *types); | |
509 | extern int mnt_fs_match_options(struct libmnt_fs *fs, const char *options); | |
510 | extern int mnt_fs_print_debug(struct libmnt_fs *fs, FILE *file); | |
a6397785 | 511 | |
4569bbea KZ |
512 | extern int mnt_fs_is_kernel(struct libmnt_fs *fs); |
513 | extern int mnt_fs_is_swaparea(struct libmnt_fs *fs); | |
514 | extern int mnt_fs_is_netfs(struct libmnt_fs *fs); | |
515 | extern int mnt_fs_is_pseudofs(struct libmnt_fs *fs); | |
309139c7 | 516 | |
8b95253f | 517 | extern void mnt_free_mntent(struct mntent *mnt); |
ba2bdf41 | 518 | extern int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt); |
8b95253f | 519 | |
6bd8b7a7 | 520 | /* tab-parse.c */ |
a6397785 | 521 | extern struct libmnt_table *mnt_new_table_from_file(const char *filename) |
4569bbea | 522 | __ul_attribute__((warn_unused_result)); |
a6397785 | 523 | extern struct libmnt_table *mnt_new_table_from_dir(const char *dirname) |
4569bbea | 524 | __ul_attribute__((warn_unused_result)); |
68164f6c | 525 | extern int mnt_table_parse_stream(struct libmnt_table *tb, FILE *f, |
ba2bdf41 KZ |
526 | const char *filename); |
527 | extern int mnt_table_parse_file(struct libmnt_table *tb, const char *filename); | |
528 | extern int mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname); | |
a6397785 | 529 | |
ba2bdf41 KZ |
530 | extern int mnt_table_parse_fstab(struct libmnt_table *tb, const char *filename); |
531 | extern int mnt_table_parse_swaps(struct libmnt_table *tb, const char *filename); | |
532 | extern int mnt_table_parse_mtab(struct libmnt_table *tb, const char *filename); | |
68164f6c | 533 | extern int mnt_table_set_parser_errcb(struct libmnt_table *tb, |
ba2bdf41 | 534 | int (*cb)(struct libmnt_table *tb, const char *filename, int line)); |
6bd8b7a7 KZ |
535 | |
536 | /* tab.c */ | |
a6397785 OO |
537 | extern struct libmnt_table *mnt_new_table(void) |
538 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 539 | extern void mnt_free_table(struct libmnt_table *tb); |
a6397785 | 540 | |
47cca899 KZ |
541 | extern void mnt_ref_table(struct libmnt_table *tb); |
542 | extern void mnt_unref_table(struct libmnt_table *tb); | |
c9f1585e | 543 | |
ba2bdf41 | 544 | extern int mnt_reset_table(struct libmnt_table *tb); |
ece5d113 | 545 | extern int mnt_table_get_nents(struct libmnt_table *tb); |
a2f17bb2 | 546 | extern int mnt_table_is_empty(struct libmnt_table *tb); |
cb90e24e | 547 | |
2bc04c11 KZ |
548 | extern int mnt_table_set_userdata(struct libmnt_table *tb, void *data); |
549 | extern void *mnt_table_get_userdata(struct libmnt_table *tb); | |
550 | ||
cb90e24e | 551 | extern void mnt_table_enable_comments(struct libmnt_table *tb, int enable); |
e670df45 | 552 | extern int mnt_table_with_comments(struct libmnt_table *tb); |
cb90e24e OO |
553 | extern const char *mnt_table_get_intro_comment(struct libmnt_table *tb); |
554 | extern int mnt_table_set_intro_comment(struct libmnt_table *tb, const char *comm); | |
555 | extern int mnt_table_append_intro_comment(struct libmnt_table *tb, const char *comm); | |
3035ba93 OO |
556 | extern int mnt_table_set_trailing_comment(struct libmnt_table *tb, const char *comm); |
557 | extern const char *mnt_table_get_trailing_comment(struct libmnt_table *tb); | |
558 | extern int mnt_table_append_trailing_comment(struct libmnt_table *tb, const char *comm); | |
cb90e24e | 559 | |
ba2bdf41 | 560 | extern int mnt_table_set_cache(struct libmnt_table *tb, struct libmnt_cache *mpc); |
ece5d113 | 561 | extern struct libmnt_cache *mnt_table_get_cache(struct libmnt_table *tb); |
ba2bdf41 KZ |
562 | extern int mnt_table_add_fs(struct libmnt_table *tb, struct libmnt_fs *fs); |
563 | extern int mnt_table_remove_fs(struct libmnt_table *tb, struct libmnt_fs *fs); | |
686a6467 KZ |
564 | extern int mnt_table_first_fs(struct libmnt_table *tb, struct libmnt_fs **fs); |
565 | extern int mnt_table_last_fs(struct libmnt_table *tb, struct libmnt_fs **fs); | |
68164f6c | 566 | extern int mnt_table_next_fs(struct libmnt_table *tb, struct libmnt_iter *itr, |
ba2bdf41 | 567 | struct libmnt_fs **fs); |
68164f6c | 568 | extern int mnt_table_next_child_fs(struct libmnt_table *tb, struct libmnt_iter *itr, |
ba2bdf41 KZ |
569 | struct libmnt_fs *parent, struct libmnt_fs **chld); |
570 | extern int mnt_table_get_root_fs(struct libmnt_table *tb, struct libmnt_fs **root); | |
68164f6c | 571 | extern int mnt_table_set_iter(struct libmnt_table *tb, struct libmnt_iter *itr, |
ba2bdf41 | 572 | struct libmnt_fs *fs); |
68164f6c | 573 | |
51fffa7b KZ |
574 | enum { |
575 | MNT_UNIQ_FORWARD = (1 << 1), /* default is backward */ | |
576 | MNT_UNIQ_KEEPTREE = (1 << 2) | |
577 | }; | |
578 | extern int mnt_table_uniq_fs(struct libmnt_table *tb, int flags, | |
579 | int (*cmp)(struct libmnt_table *, | |
580 | struct libmnt_fs *, | |
581 | struct libmnt_fs *)); | |
582 | ||
dcc15ce5 KZ |
583 | extern struct libmnt_fs *mnt_table_find_mountpoint(struct libmnt_table *tb, |
584 | const char *path, int direction); | |
68164f6c | 585 | extern struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, |
ece5d113 | 586 | const char *path, int direction); |
68164f6c | 587 | extern struct libmnt_fs *mnt_table_find_srcpath(struct libmnt_table *tb, |
ece5d113 | 588 | const char *path, int direction); |
68164f6c | 589 | extern struct libmnt_fs *mnt_table_find_tag(struct libmnt_table *tb, const char *tag, |
ece5d113 | 590 | const char *val, int direction); |
2cd28fc8 SB |
591 | extern struct libmnt_fs *mnt_table_find_target_with_option(struct libmnt_table *tb, const char *path, |
592 | const char *option, const char *val, int direction); | |
68164f6c | 593 | extern struct libmnt_fs *mnt_table_find_source(struct libmnt_table *tb, |
ece5d113 | 594 | const char *source, int direction); |
68164f6c KZ |
595 | extern struct libmnt_fs *mnt_table_find_pair(struct libmnt_table *tb, |
596 | const char *source, | |
ece5d113 | 597 | const char *target, int direction); |
677ff053 | 598 | extern struct libmnt_fs *mnt_table_find_devno(struct libmnt_table *tb, |
ece5d113 | 599 | dev_t devno, int direction); |
3fca8422 | 600 | |
68164f6c KZ |
601 | extern int mnt_table_find_next_fs(struct libmnt_table *tb, |
602 | struct libmnt_iter *itr, | |
a6397785 OO |
603 | int (*match_func)(struct libmnt_fs *, void *), |
604 | void *userdata, | |
ba2bdf41 | 605 | struct libmnt_fs **fs); |
3fca8422 | 606 | |
4569bbea | 607 | extern int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs); |
5c60a0ea | 608 | |
30493710 | 609 | /* tab_update.c */ |
a6397785 OO |
610 | extern struct libmnt_update *mnt_new_update(void) |
611 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 612 | extern void mnt_free_update(struct libmnt_update *upd); |
a6397785 | 613 | |
7b1333fa OO |
614 | extern int mnt_table_replace_file(struct libmnt_table *tb, const char *filename); |
615 | extern int mnt_table_write_file(struct libmnt_table *tb, FILE *file); | |
616 | ||
4569bbea | 617 | extern int mnt_update_is_ready(struct libmnt_update *upd); |
e6ecd606 | 618 | extern int mnt_update_set_fs(struct libmnt_update *upd, unsigned long mountflags, |
ba2bdf41 KZ |
619 | const char *target, struct libmnt_fs *fs); |
620 | extern int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc); | |
4569bbea | 621 | extern unsigned long mnt_update_get_mflags(struct libmnt_update *upd); |
ba2bdf41 | 622 | extern int mnt_update_force_rdonly(struct libmnt_update *upd, int rdonly); |
4569bbea KZ |
623 | extern const char *mnt_update_get_filename(struct libmnt_update *upd); |
624 | extern struct libmnt_fs *mnt_update_get_fs(struct libmnt_update *upd); | |
8378ede9 | 625 | |
e86623f0 KZ |
626 | /* tab_diff.c */ |
627 | enum { | |
628 | MNT_TABDIFF_MOUNT = 1, | |
629 | MNT_TABDIFF_UMOUNT, | |
630 | MNT_TABDIFF_MOVE, | |
631 | MNT_TABDIFF_REMOUNT, | |
632 | MNT_TABDIFF_PROPAGATION, /* not implemented yet (TODO) */ | |
633 | }; | |
634 | ||
a6397785 OO |
635 | extern struct libmnt_tabdiff *mnt_new_tabdiff(void) |
636 | __ul_attribute__((warn_unused_result)); | |
e86623f0 KZ |
637 | extern void mnt_free_tabdiff(struct libmnt_tabdiff *df); |
638 | ||
639 | extern int mnt_diff_tables(struct libmnt_tabdiff *df, | |
93726659 | 640 | struct libmnt_table *old_tab, |
ba2bdf41 | 641 | struct libmnt_table *new_tab); |
e86623f0 KZ |
642 | |
643 | extern int mnt_tabdiff_next_change(struct libmnt_tabdiff *df, | |
644 | struct libmnt_iter *itr, | |
645 | struct libmnt_fs **old_fs, | |
646 | struct libmnt_fs **new_fs, | |
ba2bdf41 | 647 | int *oper); |
e86623f0 | 648 | |
9b4fc141 KZ |
649 | /* monitor.c */ |
650 | enum { | |
651 | MNT_MONITOR_TYPE_USERSPACE = 1, /* userspace mount options */ | |
652 | MNT_MONITOR_TYPE_KERNEL /* kernel mount table */ | |
653 | }; | |
654 | ||
372112e9 KZ |
655 | extern struct libmnt_monitor *mnt_new_monitor(void); |
656 | extern void mnt_ref_monitor(struct libmnt_monitor *mn); | |
657 | extern void mnt_unref_monitor(struct libmnt_monitor *mn); | |
658 | ||
8f52496d | 659 | extern int mnt_monitor_enable_kernel(struct libmnt_monitor *mn, int enable); |
fc79d3ab KZ |
660 | extern int mnt_monitor_enable_userspace(struct libmnt_monitor *mn, |
661 | int enable, const char *filename); | |
372112e9 | 662 | |
f7ca1a64 | 663 | extern int mnt_monitor_get_fd(struct libmnt_monitor *mn); |
9b4fc141 KZ |
664 | extern int mnt_monitor_close_fd(struct libmnt_monitor *mn); |
665 | extern int mnt_monitor_wait(struct libmnt_monitor *mn, int timeout); | |
666 | ||
0cf83127 | 667 | extern int mnt_monitor_next_change(struct libmnt_monitor *mn, |
9b4fc141 | 668 | const char **filename, int *type); |
8f52496d | 669 | extern int mnt_monitor_event_cleanup(struct libmnt_monitor *mn); |
9b4fc141 | 670 | |
372112e9 | 671 | |
1bb1d80b KZ |
672 | /* context.c */ |
673 | ||
374fd21a KZ |
674 | /* |
675 | * Mode for mount options from fstab (or mtab), see mnt_context_set_optsmode(). | |
676 | */ | |
1bb1d80b | 677 | enum { |
30e43998 KZ |
678 | MNT_OMODE_IGNORE = (1 << 1), /* ignore mtab/fstab options */ |
679 | MNT_OMODE_APPEND = (1 << 2), /* append mtab/fstab options to existing options */ | |
680 | MNT_OMODE_PREPEND = (1 << 3), /* prepend mtab/fstab options to existing options */ | |
681 | MNT_OMODE_REPLACE = (1 << 4), /* replace existing options with options from mtab/fstab */ | |
682 | ||
683 | MNT_OMODE_FORCE = (1 << 5), /* always read mtab/fstab options */ | |
684 | ||
685 | MNT_OMODE_FSTAB = (1 << 10), /* read from fstab */ | |
686 | MNT_OMODE_MTAB = (1 << 11), /* read from mtab if fstab not enabled or failed */ | |
374fd21a | 687 | MNT_OMODE_NOTAB = (1 << 12), /* do not read fstab/mtab at all */ |
30e43998 KZ |
688 | |
689 | /* default */ | |
690 | MNT_OMODE_AUTO = (MNT_OMODE_PREPEND | MNT_OMODE_FSTAB | MNT_OMODE_MTAB), | |
691 | /* non-root users */ | |
692 | MNT_OMODE_USER = (MNT_OMODE_REPLACE | MNT_OMODE_FORCE | MNT_OMODE_FSTAB) | |
1bb1d80b KZ |
693 | }; |
694 | ||
a6397785 OO |
695 | extern struct libmnt_context *mnt_new_context(void) |
696 | __ul_attribute__((warn_unused_result)); | |
68164f6c | 697 | extern void mnt_free_context(struct libmnt_context *cxt); |
a6397785 | 698 | |
ba2bdf41 | 699 | extern int mnt_reset_context(struct libmnt_context *cxt); |
a6397785 | 700 | extern int mnt_context_is_restricted(struct libmnt_context *cxt) |
a3bb7e65 | 701 | __ul_attribute__((nonnull)); |
68164f6c | 702 | |
b70785bc | 703 | extern int mnt_context_init_helper(struct libmnt_context *cxt, |
ba2bdf41 KZ |
704 | int action, int flags); |
705 | extern int mnt_context_helper_setopt(struct libmnt_context *cxt, int c, char *arg); | |
706 | ||
707 | extern int mnt_context_set_optsmode(struct libmnt_context *cxt, int mode); | |
708 | extern int mnt_context_disable_canonicalize(struct libmnt_context *cxt, int disable); | |
709 | extern int mnt_context_enable_lazy(struct libmnt_context *cxt, int enable); | |
710 | extern int mnt_context_enable_rdonly_umount(struct libmnt_context *cxt, int enable); | |
6dede2f2 | 711 | extern int mnt_context_enable_rwonly_mount(struct libmnt_context *cxt, int enable); |
ba2bdf41 KZ |
712 | extern int mnt_context_disable_helpers(struct libmnt_context *cxt, int disable); |
713 | extern int mnt_context_enable_sloppy(struct libmnt_context *cxt, int enable); | |
714 | extern int mnt_context_enable_fake(struct libmnt_context *cxt, int enable); | |
715 | extern int mnt_context_disable_mtab(struct libmnt_context *cxt, int disable); | |
716 | extern int mnt_context_enable_force(struct libmnt_context *cxt, int enable); | |
717 | extern int mnt_context_enable_verbose(struct libmnt_context *cxt, int enable); | |
718 | extern int mnt_context_enable_loopdel(struct libmnt_context *cxt, int enable); | |
719 | extern int mnt_context_enable_fork(struct libmnt_context *cxt, int enable); | |
720 | extern int mnt_context_disable_swapmatch(struct libmnt_context *cxt, int disable); | |
a6397785 | 721 | |
4569bbea KZ |
722 | extern int mnt_context_get_optsmode(struct libmnt_context *cxt); |
723 | ||
a6397785 | 724 | extern int mnt_context_is_lazy(struct libmnt_context *cxt) |
a3bb7e65 | 725 | __ul_attribute__((nonnull)); |
a6397785 | 726 | extern int mnt_context_is_rdonly_umount(struct libmnt_context *cxt) |
a3bb7e65 | 727 | __ul_attribute__((nonnull)); |
6dede2f2 KZ |
728 | extern int mnt_context_is_rwonly_mount(struct libmnt_context *cxt) |
729 | __ul_attribute__((nonnull)); | |
a6397785 | 730 | extern int mnt_context_is_sloppy(struct libmnt_context *cxt) |
a3bb7e65 | 731 | __ul_attribute__((nonnull)); |
a6397785 | 732 | extern int mnt_context_is_fake(struct libmnt_context *cxt) |
a3bb7e65 | 733 | __ul_attribute__((nonnull)); |
a6397785 | 734 | extern int mnt_context_is_nomtab(struct libmnt_context *cxt) |
a3bb7e65 | 735 | __ul_attribute__((nonnull)); |
a6397785 | 736 | extern int mnt_context_is_force(struct libmnt_context *cxt) |
a3bb7e65 | 737 | __ul_attribute__((nonnull)); |
a6397785 | 738 | extern int mnt_context_is_verbose(struct libmnt_context *cxt) |
a3bb7e65 | 739 | __ul_attribute__((nonnull)); |
a6397785 | 740 | extern int mnt_context_is_loopdel(struct libmnt_context *cxt) |
a3bb7e65 | 741 | __ul_attribute__((nonnull)); |
a6397785 | 742 | extern int mnt_context_is_nohelpers(struct libmnt_context *cxt) |
a3bb7e65 | 743 | __ul_attribute__((nonnull)); |
a6397785 | 744 | extern int mnt_context_is_nocanonicalize(struct libmnt_context *cxt) |
a3bb7e65 | 745 | __ul_attribute__((nonnull)); |
a6397785 | 746 | extern int mnt_context_is_swapmatch(struct libmnt_context *cxt) |
a3bb7e65 | 747 | __ul_attribute__((nonnull)); |
6dede2f2 KZ |
748 | extern int mnt_context_forced_rdonly(struct libmnt_context *cxt) |
749 | __ul_attribute__((nonnull)); | |
a6397785 OO |
750 | |
751 | extern int mnt_context_is_fork(struct libmnt_context *cxt) | |
a3bb7e65 | 752 | __ul_attribute__((nonnull)); |
a6397785 | 753 | extern int mnt_context_is_parent(struct libmnt_context *cxt) |
a3bb7e65 | 754 | __ul_attribute__((nonnull)); |
a6397785 | 755 | extern int mnt_context_is_child(struct libmnt_context *cxt) |
a3bb7e65 | 756 | __ul_attribute__((nonnull)); |
d2c97887 KZ |
757 | |
758 | extern int mnt_context_wait_for_children(struct libmnt_context *cxt, | |
ba2bdf41 | 759 | int *nchildren, int *nerrs); |
d2c97887 | 760 | |
9f7472b0 | 761 | extern int mnt_context_is_fs_mounted(struct libmnt_context *cxt, |
4569bbea | 762 | struct libmnt_fs *fs, int *mounted); |
ba2bdf41 | 763 | extern int mnt_context_set_fs(struct libmnt_context *cxt, struct libmnt_fs *fs); |
4569bbea | 764 | extern struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt); |
ba2bdf41 KZ |
765 | |
766 | extern int mnt_context_set_source(struct libmnt_context *cxt, const char *source); | |
767 | extern int mnt_context_set_target(struct libmnt_context *cxt, const char *target); | |
768 | extern int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype); | |
769 | ||
4569bbea KZ |
770 | extern const char *mnt_context_get_source(struct libmnt_context *cxt); |
771 | extern const char *mnt_context_get_target(struct libmnt_context *cxt); | |
772 | extern const char *mnt_context_get_fstype(struct libmnt_context *cxt); | |
a6397785 | 773 | |
32953aeb KZ |
774 | extern void *mnt_context_get_mtab_userdata(struct libmnt_context *cxt); |
775 | extern void *mnt_context_get_fstab_userdata(struct libmnt_context *cxt); | |
776 | extern void *mnt_context_get_fs_userdata(struct libmnt_context *cxt); | |
777 | ||
ba2bdf41 KZ |
778 | extern int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr); |
779 | extern int mnt_context_append_options(struct libmnt_context *cxt, const char *optstr); | |
780 | ||
4569bbea | 781 | extern const char *mnt_context_get_options(struct libmnt_context *cxt); |
5d451abb | 782 | |
ba2bdf41 KZ |
783 | extern int mnt_context_set_fstype_pattern(struct libmnt_context *cxt, const char *pattern); |
784 | extern int mnt_context_set_options_pattern(struct libmnt_context *cxt, const char *pattern); | |
68164f6c | 785 | |
1a7a421e KZ |
786 | extern int mnt_context_set_passwd_cb(struct libmnt_context *cxt, |
787 | char *(*get)(struct libmnt_context *), | |
a6397785 | 788 | void (*release)(struct libmnt_context *, char *)) |
a6397785 | 789 | __ul_attribute__((deprecated)); |
1a7a421e | 790 | |
d84508cf | 791 | extern int mnt_context_set_tables_errcb(struct libmnt_context *cxt, |
ba2bdf41 | 792 | int (*cb)(struct libmnt_table *tb, const char *filename, int line)); |
68164f6c | 793 | extern int mnt_context_set_fstab(struct libmnt_context *cxt, |
ba2bdf41 | 794 | struct libmnt_table *tb); |
68164f6c | 795 | extern int mnt_context_get_fstab(struct libmnt_context *cxt, |
a3bb7e65 | 796 | struct libmnt_table **tb); |
ba2bdf41 | 797 | |
68164f6c | 798 | extern int mnt_context_get_mtab(struct libmnt_context *cxt, |
ba2bdf41 | 799 | struct libmnt_table **tb); |
e5c5abae KZ |
800 | extern int mnt_context_get_table(struct libmnt_context *cxt, |
801 | const char *filename, | |
ba2bdf41 | 802 | struct libmnt_table **tb); |
68164f6c | 803 | extern int mnt_context_set_cache(struct libmnt_context *cxt, |
ba2bdf41 | 804 | struct libmnt_cache *cache); |
4569bbea KZ |
805 | extern struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt); |
806 | extern struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt); | |
68164f6c | 807 | extern int mnt_context_set_mflags(struct libmnt_context *cxt, |
ba2bdf41 | 808 | unsigned long flags); |
68164f6c | 809 | extern int mnt_context_get_mflags(struct libmnt_context *cxt, |
ba2bdf41 | 810 | unsigned long *flags); |
68164f6c | 811 | extern int mnt_context_set_user_mflags(struct libmnt_context *cxt, |
ba2bdf41 | 812 | unsigned long flags); |
68164f6c | 813 | extern int mnt_context_get_user_mflags(struct libmnt_context *cxt, |
ba2bdf41 | 814 | unsigned long *flags); |
a6397785 | 815 | |
ba2bdf41 KZ |
816 | extern int mnt_context_set_mountdata(struct libmnt_context *cxt, void *data); |
817 | extern int mnt_context_apply_fstab(struct libmnt_context *cxt); | |
a6397785 | 818 | |
ba2bdf41 | 819 | extern int mnt_context_reset_status(struct libmnt_context *cxt); |
4569bbea | 820 | extern int mnt_context_get_status(struct libmnt_context *cxt); |
a6397785 | 821 | |
4569bbea KZ |
822 | extern int mnt_context_helper_executed(struct libmnt_context *cxt); |
823 | extern int mnt_context_get_helper_status(struct libmnt_context *cxt); | |
a6397785 | 824 | |
4569bbea | 825 | extern int mnt_context_syscall_called(struct libmnt_context *cxt); |
a6397785 | 826 | |
4569bbea | 827 | extern int mnt_context_get_syscall_errno(struct libmnt_context *cxt); |
8ab6accf | 828 | |
68164f6c | 829 | extern int mnt_context_strerror(struct libmnt_context *cxt, char *buf, |
ea848180 KZ |
830 | size_t bufsiz) |
831 | __ul_attribute__((deprecated)); | |
832 | ||
833 | extern int mnt_context_get_excode(struct libmnt_context *cxt, | |
834 | int rc, char *buf, size_t bufsz); | |
835 | ||
4917d842 VD |
836 | extern int mnt_context_set_target_ns(struct libmnt_context *cxt, const char *path); |
837 | extern struct libmnt_ns *mnt_context_get_target_ns(struct libmnt_context *cxt); | |
838 | extern struct libmnt_ns *mnt_context_get_origin_ns(struct libmnt_context *cxt); | |
839 | extern struct libmnt_ns *mnt_context_switch_ns(struct libmnt_context *cxt, struct libmnt_ns *ns); | |
840 | extern struct libmnt_ns *mnt_context_switch_origin_ns(struct libmnt_context *cxt); | |
841 | extern struct libmnt_ns *mnt_context_switch_target_ns(struct libmnt_context *cxt); | |
842 | ||
a6397785 OO |
843 | |
844 | /* context_mount.c */ | |
ba2bdf41 KZ |
845 | extern int mnt_context_mount(struct libmnt_context *cxt); |
846 | extern int mnt_context_umount(struct libmnt_context *cxt); | |
9f7472b0 | 847 | extern int mnt_context_next_mount(struct libmnt_context *cxt, |
a6397785 OO |
848 | struct libmnt_iter *itr, |
849 | struct libmnt_fs **fs, | |
ba2bdf41 | 850 | int *mntrc, int *ignored); |
a6397785 OO |
851 | |
852 | extern int mnt_context_prepare_mount(struct libmnt_context *cxt) | |
a6397785 | 853 | __ul_attribute__((warn_unused_result)); |
ba2bdf41 KZ |
854 | extern int mnt_context_do_mount(struct libmnt_context *cxt); |
855 | extern int mnt_context_finalize_mount(struct libmnt_context *cxt); | |
a6397785 OO |
856 | |
857 | /* context_umount.c */ | |
6506a866 KZ |
858 | extern int mnt_context_find_umount_fs(struct libmnt_context *cxt, |
859 | const char *tgt, | |
860 | struct libmnt_fs **pfs); | |
085f163b | 861 | extern int mnt_context_next_umount(struct libmnt_context *cxt, |
a6397785 OO |
862 | struct libmnt_iter *itr, |
863 | struct libmnt_fs **fs, | |
ba2bdf41 | 864 | int *mntrc, int *ignored); |
a6397785 OO |
865 | |
866 | extern int mnt_context_prepare_umount(struct libmnt_context *cxt) | |
a6397785 | 867 | __ul_attribute__((warn_unused_result)); |
ba2bdf41 KZ |
868 | extern int mnt_context_do_umount(struct libmnt_context *cxt); |
869 | extern int mnt_context_finalize_umount(struct libmnt_context *cxt); | |
a6397785 | 870 | |
4569bbea | 871 | extern int mnt_context_tab_applied(struct libmnt_context *cxt); |
ba2bdf41 | 872 | extern int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status); |
68164f6c | 873 | |
078edb2d KZ |
874 | /* |
875 | * mount(8) userspace options masks (MNT_MAP_USERSPACE map) | |
876 | */ | |
078edb2d KZ |
877 | #define MNT_MS_NOAUTO (1 << 2) |
878 | #define MNT_MS_USER (1 << 3) | |
879 | #define MNT_MS_USERS (1 << 4) | |
880 | #define MNT_MS_OWNER (1 << 5) | |
881 | #define MNT_MS_GROUP (1 << 6) | |
882 | #define MNT_MS_NETDEV (1 << 7) | |
883 | #define MNT_MS_COMMENT (1 << 8) | |
884 | #define MNT_MS_LOOP (1 << 9) | |
885 | #define MNT_MS_NOFAIL (1 << 10) | |
f309b8a7 | 886 | #define MNT_MS_UHELPER (1 << 11) |
f19c952b | 887 | #define MNT_MS_HELPER (1 << 12) |
699abc83 | 888 | #define MNT_MS_XCOMMENT (1 << 13) |
7f8b2bf3 KZ |
889 | #define MNT_MS_OFFSET (1 << 14) |
890 | #define MNT_MS_SIZELIMIT (1 << 15) | |
1a7a421e | 891 | #define MNT_MS_ENCRYPTION (1 << 16) |
0a14cc8b | 892 | #define MNT_MS_XFSTABCOMM (1 << 17) |
078edb2d KZ |
893 | |
894 | /* | |
895 | * mount(2) MS_* masks (MNT_MAP_LINUX map) | |
896 | */ | |
897 | #ifndef MS_RDONLY | |
898 | #define MS_RDONLY 1 /* Mount read-only */ | |
899 | #endif | |
900 | #ifndef MS_NOSUID | |
901 | #define MS_NOSUID 2 /* Ignore suid and sgid bits */ | |
902 | #endif | |
903 | #ifndef MS_NODEV | |
904 | #define MS_NODEV 4 /* Disallow access to device special files */ | |
905 | #endif | |
906 | #ifndef MS_NOEXEC | |
907 | #define MS_NOEXEC 8 /* Disallow program execution */ | |
908 | #endif | |
909 | #ifndef MS_SYNCHRONOUS | |
910 | #define MS_SYNCHRONOUS 16 /* Writes are synced at once */ | |
911 | #endif | |
912 | #ifndef MS_REMOUNT | |
913 | #define MS_REMOUNT 32 /* Alter flags of a mounted FS */ | |
914 | #endif | |
915 | #ifndef MS_MANDLOCK | |
916 | #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */ | |
917 | #endif | |
918 | #ifndef MS_DIRSYNC | |
919 | #define MS_DIRSYNC 128 /* Directory modifications are synchronous */ | |
920 | #endif | |
921 | #ifndef MS_NOATIME | |
922 | #define MS_NOATIME 0x400 /* 1024: Do not update access times. */ | |
923 | #endif | |
924 | #ifndef MS_NODIRATIME | |
925 | #define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */ | |
926 | #endif | |
927 | #ifndef MS_BIND | |
d58b3157 | 928 | #define MS_BIND 0x1000 /* 4096: Mount existing tree elsewhere as well */ |
078edb2d KZ |
929 | #endif |
930 | #ifndef MS_MOVE | |
d58b3157 | 931 | #define MS_MOVE 0x2000 /* 8192: Atomically move the tree */ |
078edb2d KZ |
932 | #endif |
933 | #ifndef MS_REC | |
934 | #define MS_REC 0x4000 /* 16384: Recursive loopback */ | |
935 | #endif | |
5af1532e | 936 | #ifndef MS_SILENT |
0dc5e9ba | 937 | #define MS_SILENT 0x8000 /* 32768: Don't emit certain kernel messages */ |
078edb2d KZ |
938 | #endif |
939 | #ifndef MS_UNBINDABLE | |
0dc5e9ba | 940 | #define MS_UNBINDABLE (1<<17) /* 131072: Make unbindable */ |
078edb2d KZ |
941 | #endif |
942 | #ifndef MS_PRIVATE | |
0dc5e9ba | 943 | #define MS_PRIVATE (1<<18) /* 262144: Make private */ |
078edb2d KZ |
944 | #endif |
945 | #ifndef MS_SLAVE | |
0dc5e9ba | 946 | #define MS_SLAVE (1<<19) /* 524288: Make slave */ |
078edb2d KZ |
947 | #endif |
948 | #ifndef MS_SHARED | |
0dc5e9ba BS |
949 | #define MS_SHARED (1<<20) /* 1048576: Make shared */ |
950 | #endif | |
951 | #ifndef MS_RELATIME | |
952 | #define MS_RELATIME (1<<21) /* 2097152: Update atime relative to mtime/ctime */ | |
078edb2d KZ |
953 | #endif |
954 | #ifndef MS_I_VERSION | |
0dc5e9ba | 955 | #define MS_I_VERSION (1<<23) /* Update the inode I_version field */ |
078edb2d KZ |
956 | #endif |
957 | #ifndef MS_STRICTATIME | |
0dc5e9ba | 958 | #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ |
078edb2d | 959 | #endif |
8c7f073a KZ |
960 | #ifndef MS_LAZYTIME |
961 | #define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ | |
962 | #endif | |
963 | ||
078edb2d KZ |
964 | |
965 | /* | |
8d6de224 KZ |
966 | * Magic mount flag number. Had to be or-ed to the flag values. Deprecated and |
967 | * no more used since libmount v2.33; required for Linux <= 2.4. | |
078edb2d KZ |
968 | */ |
969 | #ifndef MS_MGC_VAL | |
970 | #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */ | |
971 | #endif | |
972 | #ifndef MS_MGC_MSK | |
973 | #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */ | |
974 | #endif | |
975 | ||
976 | ||
977 | /* Shared-subtree options */ | |
978 | #define MS_PROPAGATION (MS_SHARED|MS_SLAVE|MS_UNBINDABLE|MS_PRIVATE) | |
979 | ||
980 | /* Options that we make ordinary users have by default. */ | |
981 | #define MS_SECURE (MS_NOEXEC|MS_NOSUID|MS_NODEV) | |
982 | ||
983 | /* Options that we make owner-mounted devices have by default */ | |
984 | #define MS_OWNERSECURE (MS_NOSUID|MS_NODEV) | |
985 | ||
f1cde479 KZ |
986 | #ifdef __cplusplus |
987 | } | |
988 | #endif | |
989 | ||
990 | #endif /* _LIBMOUNT_MOUNT_H */ |