2 * mount.h - libmount API
4 * Copyright (C) 2008-2009 Karel Zak <kzak@redhat.com>
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.
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.
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.
21 #ifndef _LIBMOUNT_MOUNT_H
22 #define _LIBMOUNT_MOUNT_H
30 #include <sys/types.h>
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@
40 * Stores canonicalized paths and evaluated tags
47 * Stores information about the locked file (e.g. /etc/mtab)
54 * Generic iterator (stores state about lists)
61 * Mount options description (map)
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 */
71 * mount options map masks
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 */
81 * Parsed fstab/mtab/mountinfo entry
88 * List of struct libmnt_fs entries (parsed fstab/mtab/mountinfo)
95 * /etc/mtab or utab update description
102 * Mount/umount status
104 struct libmnt_context
;
109 * Mount tables monitor
111 struct libmnt_monitor
;
116 * Stores mountinfo state
118 struct libmnt_tabdiff
;
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
134 * See also mnt_context_get_syscall_errno() and mnt_context_get_helper_status().
139 * not found required entry in fstab
141 #define MNT_ERR_NOFSTAB 5000
145 * failed to detect filesystem type
147 #define MNT_ERR_NOFSTYPE 5001
151 * required mount source undefined
153 #define MNT_ERR_NOSOURCE 5002
157 * loopdev setup failed, errno set by libc
159 #define MNT_ERR_LOOPDEV 5003
163 * failed to parse/use userspace mount options
165 #define MNT_ERR_MOUNTOPT 5004
167 * MNT_ERR_APPLYFLAGS:
169 * failed to apply MS_PROPAGATION flags
171 #define MNT_ERR_APPLYFLAGS 5005
175 * libblkid detected more filesystems on the device
177 #define MNT_ERR_AMBIFS 5006
179 #ifndef __GNUC_PREREQ
180 # if defined __GNUC__ && defined __GNUC_MINOR__
181 # define __GNUC_PREREQ(maj, min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
183 # define __GNUC_PREREQ(maj, min) 0
187 #ifndef __ul_attribute__
188 # if __GNUC_PREREQ (3, 4)
189 # define __ul_attribute__(_a_) __attribute__(_a_)
191 # define __ul_attribute__(_a_)
197 extern void mnt_init_debug(int mask
);
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
);
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
));
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
);
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
));
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
);
230 extern void mnt_ref_cache(struct libmnt_cache
*cache
);
231 extern void mnt_unref_cache(struct libmnt_cache
*cache
);
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
);
237 extern int mnt_cache_device_has_tag(struct libmnt_cache
*cache
,
242 extern char *mnt_cache_find_tag_value(struct libmnt_cache
*cache
,
243 const char *devname
, const char *token
);
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
));
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
,
265 extern int mnt_optstr_prepend_option(char **optstr
, const char *name
,
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
,
272 extern int mnt_optstr_remove_option(char **optstr
, const char *name
);
273 extern int mnt_optstr_deduplicate_option(char **optstr
, const char *name
);
275 extern int mnt_split_optstr(const char *optstr
,
276 char **user
, char **vfs
, char **fs
,
277 int ignore_user
, int ignore_vfs
);
279 extern int mnt_optstr_get_options(const char *optstr
, char **subset
,
280 const struct libmnt_optmap
*map
, int ignore
);
282 extern int mnt_optstr_get_flags(const char *optstr
, unsigned long *flags
,
283 const struct libmnt_optmap
*map
);
285 extern int mnt_optstr_apply_flags(char **optstr
, unsigned long flags
,
286 const struct libmnt_optmap
*map
);
291 MNT_ITER_FORWARD
= 0,
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
);
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
));
308 extern const struct libmnt_optmap
*mnt_get_builtin_optmap(int id
);
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
);
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
);
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
);
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
);
336 extern int mnt_fs_get_tag(struct libmnt_fs
*fs
, const char **name
,
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
);
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
));
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
);
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
);
360 extern int mnt_fs_get_option(struct libmnt_fs
*fs
, const char *name
,
361 char **value
, size_t *valsz
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
409 extern void mnt_free_mntent(struct mntent
*mnt
);
410 extern int mnt_fs_to_mntent(struct libmnt_fs
*fs
, struct mntent
**mnt
);
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
);
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
));
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
);
433 extern void mnt_ref_table(struct libmnt_table
*tb
);
434 extern void mnt_unref_table(struct libmnt_table
*tb
);
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
);
440 extern int mnt_table_set_userdata(struct libmnt_table
*tb
, void *data
);
441 extern void *mnt_table_get_userdata(struct libmnt_table
*tb
);
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
);
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
);
467 MNT_UNIQ_FORWARD
= (1 << 1), /* default is backward */
468 MNT_UNIQ_KEEPTREE
= (1 << 2)
470 extern int mnt_table_uniq_fs(struct libmnt_table
*tb
, int flags
,
471 int (*cmp
)(struct libmnt_table
*,
473 struct libmnt_fs
*));
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
,
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
);
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 *),
495 struct libmnt_fs
**fs
);
497 extern int mnt_table_is_fs_mounted(struct libmnt_table
*tb
, struct libmnt_fs
*fstab_fs
);
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
);
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
);
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
);
518 MNT_TABDIFF_MOUNT
= 1,
522 MNT_TABDIFF_PROPAGATION
, /* not implemented yet (TODO) */
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
);
529 extern int mnt_diff_tables(struct libmnt_tabdiff
*df
,
530 struct libmnt_table
*old_tab
,
531 struct libmnt_table
*new_tab
);
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
,
541 MNT_MONITOR_TYPE_USERSPACE
= 1, /* userspace mount options */
542 MNT_MONITOR_TYPE_KERNEL
/* kernel mount table */
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
);
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
);
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
);
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
);
565 * Mode for mount options from fstab (or mtab), see mnt_context_set_optsmode().
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 */
573 MNT_OMODE_FORCE
= (1 << 5), /* always read mtab/fstab options */
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 */
580 MNT_OMODE_AUTO
= (MNT_OMODE_PREPEND
| MNT_OMODE_FSTAB
| MNT_OMODE_MTAB
),
582 MNT_OMODE_USER
= (MNT_OMODE_REPLACE
| MNT_OMODE_FORCE
| MNT_OMODE_FSTAB
)
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
);
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
));
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
);
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
);
611 extern int mnt_context_get_optsmode(struct libmnt_context
*cxt
);
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
));
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
));
643 extern int mnt_context_wait_for_children(struct libmnt_context
*cxt
,
644 int *nchildren
, int *nerrs
);
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
);
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
);
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
);
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
);
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
);
666 extern const char *mnt_context_get_options(struct libmnt_context
*cxt
);
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
);
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
));
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
);
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
);
701 extern int mnt_context_set_mountdata(struct libmnt_context
*cxt
, void *data
);
702 extern int mnt_context_apply_fstab(struct libmnt_context
*cxt
);
704 extern int mnt_context_reset_status(struct libmnt_context
*cxt
);
705 extern int mnt_context_get_status(struct libmnt_context
*cxt
);
707 extern int mnt_context_helper_executed(struct libmnt_context
*cxt
);
708 extern int mnt_context_get_helper_status(struct libmnt_context
*cxt
);
710 extern int mnt_context_syscall_called(struct libmnt_context
*cxt
);
712 extern int mnt_context_get_syscall_errno(struct libmnt_context
*cxt
);
714 extern int mnt_context_strerror(struct libmnt_context
*cxt
, char *buf
,
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
);
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
);
730 /* context_umount.c */
731 extern int mnt_context_find_umount_fs(struct libmnt_context
*cxt
,
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
);
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
);
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
);
748 * mount(8) userspace options masks (MNT_MAP_USERSPACE map)
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)
767 * mount(2) MS_* masks (MNT_MAP_LINUX map)
770 #define MS_RDONLY 1 /* Mount read-only */
773 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
776 #define MS_NODEV 4 /* Disallow access to device special files */
779 #define MS_NOEXEC 8 /* Disallow program execution */
781 #ifndef MS_SYNCHRONOUS
782 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
785 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
788 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
791 #define MS_DIRSYNC 128 /* Directory modifications are synchronous */
794 #define MS_NOATIME 0x400 /* 1024: Do not update access times. */
796 #ifndef MS_NODIRATIME
797 #define MS_NODIRATIME 0x800 /* 2048: Don't update directory access times */
800 #define MS_BIND 0x1000 /* 4096: Mount existing tree elsewhere as well */
803 #define MS_MOVE 0x2000 /* 8192: Atomically move the tree */
806 #define MS_REC 0x4000 /* 16384: Recursive loopback */
809 #define MS_SILENT 0x8000 /* 32768: Don't emit certain kernel messages */
811 #ifndef MS_UNBINDABLE
812 #define MS_UNBINDABLE (1<<17) /* 131072: Make unbindable */
815 #define MS_PRIVATE (1<<18) /* 262144: Make private */
818 #define MS_SLAVE (1<<19) /* 524288: Make slave */
821 #define MS_SHARED (1<<20) /* 1048576: Make shared */
824 #define MS_RELATIME (1<<21) /* 2097152: Update atime relative to mtime/ctime */
827 #define MS_I_VERSION (1<<23) /* Update the inode I_version field */
829 #ifndef MS_STRICTATIME
830 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
834 * Magic mount flag number. Had to be or-ed to the flag values.
837 #define MS_MGC_VAL 0xC0ED0000 /* magic flag number to indicate "new" flags */
840 #define MS_MGC_MSK 0xffff0000 /* magic flag number mask */
844 /* Shared-subtree options */
845 #define MS_PROPAGATION (MS_SHARED|MS_SLAVE|MS_UNBINDABLE|MS_PRIVATE)
847 /* Options that we make ordinary users have by default. */
848 #define MS_SECURE (MS_NOEXEC|MS_NOSUID|MS_NODEV)
850 /* Options that we make owner-mounted devices have by default */
851 #define MS_OWNERSECURE (MS_NOSUID|MS_NODEV)
857 #endif /* _LIBMOUNT_MOUNT_H */