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