1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
3 * mountP.h - private library header file
5 * This file is part of libmount from util-linux project.
7 * Copyright (C) 2008-2018 Karel Zak <kzak@redhat.com>
9 * libmount is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 #ifndef _LIBMOUNT_PRIVATE_H
15 #define _LIBMOUNT_PRIVATE_H
21 #include <sys/types.h>
36 #include "mount-api-utils.h"
41 #define MNT_DEBUG_HELP (1 << 0)
42 #define MNT_DEBUG_INIT (1 << 1)
43 #define MNT_DEBUG_CACHE (1 << 2)
44 #define MNT_DEBUG_OPTIONS (1 << 3)
45 #define MNT_DEBUG_LOCKS (1 << 4)
46 #define MNT_DEBUG_TAB (1 << 5)
47 #define MNT_DEBUG_FS (1 << 6)
48 #define MNT_DEBUG_UPDATE (1 << 7)
49 #define MNT_DEBUG_UTILS (1 << 8)
50 #define MNT_DEBUG_CXT (1 << 9)
51 #define MNT_DEBUG_DIFF (1 << 10)
52 #define MNT_DEBUG_MONITOR (1 << 11)
53 #define MNT_DEBUG_BTRFS (1 << 12)
54 #define MNT_DEBUG_LOOP (1 << 13)
55 #define MNT_DEBUG_VERITY (1 << 14)
56 #define MNT_DEBUG_HOOK (1 << 15)
57 #define MNT_DEBUG_OPTLIST (1 << 16)
58 #define MNT_DEBUG_STATMNT (1 << 17)
60 #define MNT_DEBUG_ALL 0xFFFFFF
62 UL_DEBUG_DECLARE_MASK(libmount
);
63 #define DBG(m, x) __UL_DBG(libmount, MNT_DEBUG_, m, x)
64 #define ON_DBG(m, x) __UL_DBG_CALL(libmount, MNT_DEBUG_, m, x)
65 #define DBG_FLUSH __UL_DBG_FLUSH(libmount, MNT_DEBUG_)
67 #define UL_DEBUG_CURRENT_MASK UL_DEBUG_MASK(libmount)
71 * NLS -- the library has to be independent on main program, so define
72 * UL_TEXTDOMAIN_EXPLICIT before you include nls.h.
74 * Now we use util-linux.po (=PACKAGE), rather than maintain the texts
75 * in the separate libmount.po file.
77 #define LIBMOUNT_TEXTDOMAIN PACKAGE
78 #define UL_TEXTDOMAIN_EXPLICIT LIBMOUNT_TEXTDOMAIN
82 /* extension for files in the directory */
83 #define MNT_MNTTABDIR_EXT ".fstab"
85 /* library private paths */
86 #define MNT_RUNTIME_TOPDIR "/run"
87 /* private userspace mount table */
88 #define MNT_PATH_UTAB MNT_RUNTIME_TOPDIR "/mount/utab"
89 /* temporary mount target */
90 #define MNT_PATH_TMPTGT MNT_RUNTIME_TOPDIR "/mount/tmptgt"
92 #define MNT_UTAB_HEADER "# libmount utab file\n"
97 int (*body
)(struct libmnt_test
*ts
, int argc
, char *argv
[]);
102 extern int mnt_run_test(struct libmnt_test
*tests
, int argc
, char *argv
[]);
105 /* private tab_listmount.c */
106 struct libmnt_listmnt
;
109 extern int mnt_valid_tagname(const char *tagname
);
111 extern const char *mnt_statfs_get_fstype(struct statfs
*vfs
);
112 extern int is_file_empty(const char *name
);
114 extern int mnt_is_readonly(const char *path
)
115 __attribute__((nonnull
));
117 extern int mnt_parse_offset(const char *str
, size_t len
, uintmax_t *res
);
119 extern int mnt_chdir_to_parent(const char *target
, char **filename
);
121 extern char *mnt_get_username(const uid_t uid
);
122 extern int mnt_get_uid(const char *username
, uid_t
*uid
);
123 extern int mnt_get_gid(const char *groupname
, gid_t
*gid
);
124 extern int mnt_parse_uid(const char *user
, size_t user_len
, uid_t
*gid
);
125 extern int mnt_parse_gid(const char *group
, size_t group_len
, gid_t
*gid
);
126 extern int mnt_parse_mode(const char *mode
, size_t mode_len
, mode_t
*gid
);
127 extern int mnt_in_group(gid_t gid
);
129 extern int mnt_open_uniq_filename(const char *filename
, char **name
);
131 extern int mnt_has_regular_utab(const char **utab
, int *writable
);
132 extern const char *mnt_get_utab_path(void);
134 extern int mnt_get_filesystems(char ***filesystems
, const char *pattern
);
135 extern void mnt_free_filesystems(char **filesystems
);
137 extern char *mnt_get_kernel_cmdline_option(const char *name
);
139 extern int mnt_safe_stat(const char *target
, struct stat
*st
);
140 extern int mnt_safe_lstat(const char *target
, struct stat
*st
);
141 extern int mnt_is_path(const char *target
);
143 extern int mnt_tmptgt_unshare(int *old_ns_fd
);
144 extern int mnt_tmptgt_cleanup(int old_ns_fd
);
146 extern int mnt_id_from_fd(int fd
, uint64_t *uniq_id
, int *id
);
149 extern int is_mountinfo(struct libmnt_table
*tb
);
150 extern int mnt_table_set_parser_fltrcb( struct libmnt_table
*tb
,
151 int (*cb
)(struct libmnt_fs
*, void *),
154 extern int __mnt_table_parse_mountinfo(struct libmnt_table
*tb
,
155 const char *filename
,
156 struct libmnt_table
*u_tb
);
158 extern struct libmnt_fs
*mnt_table_get_fs_root(struct libmnt_table
*tb
,
159 struct libmnt_fs
*fs
,
160 unsigned long mountflags
,
163 extern int __mnt_table_is_fs_mounted( struct libmnt_table
*tb
,
164 struct libmnt_fs
*fstab_fs
,
165 const char *tgt_prefix
);
167 extern int mnt_table_enable_noautofs(struct libmnt_table
*tb
, int ignore
);
168 extern int mnt_table_is_noautofs(struct libmnt_table
*tb
);
170 /* tab_listmount.c */
171 extern int mnt_table_next_lsmnt(struct libmnt_table
*tb
, int direction
);
172 extern int mnt_table_reset_listmount(struct libmnt_table
*tb
);
173 extern int mnt_table_want_listmount(struct libmnt_table
*tb
);
179 struct list_head
*p
; /* current position */
180 struct list_head
*head
; /* start position */
181 int direction
; /* MNT_ITER_{FOR,BACK}WARD */
184 #define IS_ITER_FORWARD(_i) ((_i)->direction == MNT_ITER_FORWARD)
185 #define IS_ITER_BACKWARD(_i) ((_i)->direction == MNT_ITER_BACKWARD)
187 #define MNT_ITER_INIT(itr, list) \
189 (itr)->p = IS_ITER_FORWARD(itr) ? \
190 (list)->next : (list)->prev; \
191 (itr)->head = (list); \
194 #define MNT_ITER_GET_ENTRY(itr, restype, member) \
195 list_entry((itr)->p, restype, member)
197 #define MNT_ITER_ITERATE(itr) \
199 (itr)->p = IS_ITER_FORWARD(itr) ? \
200 (itr)->p->next : (itr)->p->prev; \
205 * statmount setting; shared between tables and filesystems
207 struct libmnt_statmnt
{
209 uint64_t mask
; /* default statmount() mask */
211 struct ul_statmount
*buf
;
214 unsigned int disabled
: 1; /* enable or disable statmount() */
219 * This struct represents one entry in a fstab/mountinfo file.
220 * (note that fstab[1] means the first column from fstab, and so on...)
223 struct list_head ents
;
224 struct libmnt_table
*tab
;
226 int refcount
; /* reference counter */
228 unsigned int opts_age
; /* to sync with optlist */
229 struct libmnt_optlist
*optlist
;
231 int id
; /* mountinfo[1]: ID */
232 uint64_t uniq_id
; /* unique node ID; statx(STATX_MNT_ID_UNIQUE); statmount->mnt_id */
233 uint64_t ns_id
; /* namespace ID; statmount->mnt_ns_id */
235 int parent
; /* mountinfo[2]: parent */
236 uint64_t uniq_parent
; /* unique parent ID; statmount->mnt_parent_id */
237 dev_t devno
; /* mountinfo[3]: st_dev */
239 char *bindsrc
; /* utab, full path from fstab[1] for bind mounts */
241 char *source
; /* fstab[1], mountinfo[10], swaps[1]:
242 * source dev, file, dir or TAG */
243 char *tagname
; /* fstab[1]: tag name - "LABEL", "UUID", ..*/
244 char *tagval
; /* tag value */
246 char *root
; /* mountinfo[4]: root of the mount within the FS */
247 char *target
; /* mountinfo[5], fstab[2]: mountpoint */
248 char *fstype
; /* mountinfo[9], fstab[3]: filesystem type */
250 char *optstr
; /* fstab[4], merged options */
251 char *vfs_optstr
; /* mountinfo[6]: fs-independent (VFS) options */
253 char *opt_fields
; /* mountinfo[7]: optional fields */
254 uint64_t propagation
; /* statmmount() or parsed opt_fields */
256 char *fs_optstr
; /* mountinfo[11]: fs-dependent options */
257 char *user_optstr
; /* userspace mount options */
258 char *attrs
; /* mount attributes */
260 int freq
; /* fstab[5]: dump frequency in days */
261 int passno
; /* fstab[6]: pass number on parallel fsck */
264 char *swaptype
; /* swaps[2]: device type (partition, file, ...) */
265 off_t size
; /* swaps[3]: swaparea size */
266 off_t usedsize
; /* swaps[4]: used size */
267 int priority
; /* swaps[5]: swap priority */
269 int flags
; /* MNT_FS_* flags */
270 pid_t tid
; /* /proc/<tid>/mountinfo otherwise zero */
272 uint64_t stmnt_done
; /* mask of already called masks */
273 struct libmnt_statmnt
*stmnt
; /* statmount() stuff */
275 char *comment
; /* fstab comment */
277 void *userdata
; /* library independent data */
283 #define MNT_FS_PSEUDO (1 << 1) /* pseudo filesystem */
284 #define MNT_FS_NET (1 << 2) /* network filesystem */
285 #define MNT_FS_SWAP (1 << 3) /* swap device */
286 #define MNT_FS_KERNEL (1 << 4) /* data from /proc/{mounts,self/mountinfo} */
287 #define MNT_FS_MERGED (1 << 5) /* already merged data from /run/mount/utab */
289 #ifdef HAVE_STATMOUNT_API
290 # define mnt_fs_try_statmount(FS, MEMBER, FLAGS) __extension__ ({ \
293 && !(FS)->stmnt->disabled \
294 && ((FLAGS) & ~((FS)->stmnt_done))) \
295 mnt_fs_fetch_statmount((FS), (FLAGS)); })
300 * fstab/mountinfo file
302 struct libmnt_table
{
303 int fmt
; /* MNT_FMT_* file format */
304 int nents
; /* number of entries */
305 int refcount
; /* reference counter */
306 int comms
; /* enable/disable comment parsing */
307 char *comm_intro
; /* First comment in file */
308 char *comm_tail
; /* Last comment in file */
310 struct libmnt_cache
*cache
; /* canonicalized paths/tags cache */
312 int (*errcb
)(struct libmnt_table
*tb
,
313 const char *filename
, int line
);
315 int (*fltrcb
)(struct libmnt_fs
*fs
, void *data
);
318 struct libmnt_listmnt
*lsmnt
; /* listmount() stuff */
319 struct libmnt_statmnt
*stmnt
; /* statmount() stuff */
321 int noautofs
; /* ignore autofs mounts */
323 struct list_head ents
; /* list of entries (libmnt_fs) */
327 extern struct libmnt_table
*__mnt_new_table_from_file(const char *filename
, int fmt
, int empty_for_enoent
);
334 MNT_FMT_FSTAB
, /* /etc/{fs,m}tab */
335 MNT_FMT_MTAB
= MNT_FMT_FSTAB
, /* alias */
336 MNT_FMT_MOUNTINFO
, /* /proc/#/mountinfo */
337 MNT_FMT_UTAB
, /* /run/mount/utab */
338 MNT_FMT_SWAPS
/* /proc/swaps */
344 * TODO: this will be public one day when libmount will support modules for
345 * stuff like veritydev.c.
348 MNT_STAGE_PREP_SOURCE
= 1, /* mount source preparation */
349 MNT_STAGE_PREP_TARGET
, /* mount target preparation */
350 MNT_STAGE_PREP_OPTIONS
, /* mount options preparation */
351 MNT_STAGE_PREP
, /* all prepared */
353 MNT_STAGE_MOUNT_PRE
= 100, /* before mount */
354 MNT_STAGE_MOUNT
, /* mount(2) or fsmount(2) or tree-clone */
355 MNT_STAGE_MOUNT_POST
, /* after mount */
357 MNT_STAGE_POST
= 200 /* all is done */
360 struct libmnt_hookset
{
361 const char *name
; /* hook set name */
364 int (*firstcall
)(struct libmnt_context
*, const struct libmnt_hookset
*, void *);
366 int (*deinit
)(struct libmnt_context
*, const struct libmnt_hookset
*); /* cleanup function */
370 extern const struct libmnt_hookset hookset_mount_legacy
;
371 extern const struct libmnt_hookset hookset_mount
;
372 extern const struct libmnt_hookset hookset_mkdir
;
373 extern const struct libmnt_hookset hookset_subdir
;
374 extern const struct libmnt_hookset hookset_owner
;
375 extern const struct libmnt_hookset hookset_idmap
;
376 extern const struct libmnt_hookset hookset_loopdev
;
377 #ifdef HAVE_CRYPTSETUP
378 extern const struct libmnt_hookset hookset_veritydev
;
380 #ifdef HAVE_LIBSELINUX
381 extern const struct libmnt_hookset hookset_selinux
;
384 extern int mnt_context_deinit_hooksets(struct libmnt_context
*cxt
);
385 extern const struct libmnt_hookset
*mnt_context_get_hookset(struct libmnt_context
*cxt
, const char *name
);
387 extern int mnt_context_set_hookset_data(struct libmnt_context
*cxt
,
388 const struct libmnt_hookset
*hs
,
391 extern void *mnt_context_get_hookset_data(struct libmnt_context
*cxt
,
392 const struct libmnt_hookset
*hs
);
394 extern int mnt_context_has_hook(struct libmnt_context
*cxt
,
395 const struct libmnt_hookset
*hs
,
399 extern int mnt_context_append_hook(struct libmnt_context
*cxt
,
400 const struct libmnt_hookset
*hs
,
403 int (*func
)(struct libmnt_context
*,
404 const struct libmnt_hookset
*,
406 extern int mnt_context_insert_hook(struct libmnt_context
*cxt
,
408 const struct libmnt_hookset
*hs
,
411 int (*func
)(struct libmnt_context
*,
412 const struct libmnt_hookset
*,
415 extern int mnt_context_remove_hook(struct libmnt_context
*cxt
,
416 const struct libmnt_hookset
*hs
,
419 extern int mnt_context_call_hooks(struct libmnt_context
*cxt
, int stage
);
425 int fd
; /* file descriptor of namespace, -1 when inactive */
426 struct libmnt_cache
*cache
; /* paths cache associated with NS */
430 * Mount context -- high-level API
432 struct libmnt_context
434 int action
; /* MNT_ACT_{MOUNT,UMOUNT} */
435 int restricted
; /* root or not? */
437 char *fstype_pattern
; /* for mnt_match_fstype() */
438 char *optstr_pattern
; /* for mnt_match_options() */
440 struct libmnt_fs
*fs
; /* filesystem description (type, mountpoint, device, ...) */
442 struct libmnt_table
*fstab
; /* fstab entries */
443 struct libmnt_table
*mountinfo
; /* already mounted filesystems */
444 struct libmnt_table
*utab
; /* rarely used by umount only */
446 int (*table_errcb
)(struct libmnt_table
*tb
, /* callback for libmnt_table structs */
447 const char *filename
, int line
);
449 int (*table_fltrcb
)(struct libmnt_fs
*fs
, void *data
); /* callback for libmnt_table structs */
450 void *table_fltrcb_data
;
452 char *(*pwd_get_cb
)(struct libmnt_context
*); /* get encryption password */
453 void (*pwd_release_cb
)(struct libmnt_context
*, char *); /* release password */
455 int optsmode
; /* fstab optstr mode MNT_OPTSMODE_{AUTO,FORCE,IGNORE} */
457 const void *mountdata
; /* final mount(2) data, string or binary data */
459 struct libmnt_cache
*cache
; /* paths cache */
460 struct libmnt_lock
*lock
; /* utab lock */
461 struct libmnt_update
*update
; /* utab update */
463 struct libmnt_optlist
*optlist
; /* parsed mount options */
464 struct libmnt_optlist
*optlist_saved
; /* save/apply context template */
466 const struct libmnt_optmap
*map_linux
; /* system options map */
467 const struct libmnt_optmap
*map_userspace
; /* userspace options map */
469 const char *mountinfo_path
; /* usually /proc/self/moutinfo */
471 const char *utab_path
; /* path to utab */
472 int utab_writable
; /* is utab writable */
474 char *tgt_prefix
; /* path used for all targets */
476 int flags
; /* private context flags */
478 char *helper
; /* name of the used /sbin/[u]mount.<type> helper */
479 int helper_status
; /* helper wait(2) status */
480 int helper_exec_status
; /* 1: not called yet, 0: success, <0: -errno */
482 pid_t
*children
; /* "mount -a --fork" PIDs */
483 int nchildren
; /* number of children */
484 pid_t pid
; /* 0=parent; PID=child */
486 int syscall_status
; /* 1: not called yet, 0: success, <0: -errno */
487 const char *syscall_name
; /* failed syscall name */
489 char **mesgs
; /* library or kernel messages (NULL terminated array) */
491 struct libmnt_ns ns_orig
; /* original namespace */
492 struct libmnt_ns ns_tgt
; /* target namespace */
493 struct libmnt_ns
*ns_cur
; /* pointer to current namespace */
495 unsigned int enabled_textdomain
: 1; /* bindtextdomain() called */
496 unsigned int noautofs
: 1; /* ignore autofs mounts */
497 unsigned int has_selinux_opt
: 1; /* temporary for broken fsconfig() syscall */
498 unsigned int force_clone
: 1; /* OPEN_TREE_CLONE */
500 struct list_head hooksets_datas
; /* global hooksets data */
501 struct list_head hooksets_hooks
; /* global hooksets data */
505 #define MNT_FL_NOMTAB (1 << 1)
506 #define MNT_FL_FAKE (1 << 2)
507 #define MNT_FL_SLOPPY (1 << 3)
508 #define MNT_FL_VERBOSE (1 << 4)
509 #define MNT_FL_NOHELPERS (1 << 5)
510 #define MNT_FL_LOOPDEL (1 << 6)
511 #define MNT_FL_LAZY (1 << 7)
512 #define MNT_FL_FORCE (1 << 8)
513 #define MNT_FL_NOCANONICALIZE (1 << 9)
514 #define MNT_FL_RDONLY_UMOUNT (1 << 11) /* remount,ro after EBUSY umount(2) */
515 #define MNT_FL_FORK (1 << 12)
516 #define MNT_FL_NOSWAPMATCH (1 << 13)
517 #define MNT_FL_RWONLY_MOUNT (1 << 14) /* explicit mount -w; never try read-only */
518 #define MNT_FL_ONLYONCE (1 << 15)
520 #define MNT_FL_MOUNTDATA (1 << 20)
521 #define MNT_FL_TAB_APPLIED (1 << 21) /* fstab merged to cxt->fs */
522 #define MNT_FL_MOUNTFLAGS_MERGED (1 << 22) /* MS_* flags was read from optstr */
523 #define MNT_FL_SAVED_USER (1 << 23)
524 #define MNT_FL_PREPARED (1 << 24)
525 #define MNT_FL_HELPER (1 << 25) /* [u]mount.<type> */
526 #define MNT_FL_MOUNTOPTS_FIXED (1 << 27)
527 #define MNT_FL_TABPATHS_CHECKED (1 << 28)
528 #define MNT_FL_FORCED_RDONLY (1 << 29) /* mounted read-only on write-protected device */
529 #define MNT_FL_VERITYDEV_READY (1 << 30) /* /dev/mapper/<FOO> initialized by the library */
532 #define MNT_FL_DEFAULT 0
534 /* Flags usable with MS_BIND|MS_REMOUNT */
535 #define MNT_BIND_SETTABLE (MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_NOATIME|MS_NODIRATIME|MS_RELATIME|MS_RDONLY|MS_NOSYMFOLLOW)
539 extern const struct libmnt_optmap
*mnt_optmap_get_entry(
540 struct libmnt_optmap
const **maps
,
544 const struct libmnt_optmap
**mapent
);
547 extern int mnt_optstr_remove_option_at(char **optstr
, char *begin
, char *end
);
548 extern int mnt_optstr_get_missing(const char *optstr
, const char *wanted
, char **missing
);
550 extern int mnt_buffer_append_option(struct ul_buffer
*buf
,
551 const char *name
, size_t namesz
,
552 const char *val
, size_t valsz
, int quoted
);
556 struct libmnt_optlist
;
558 extern struct libmnt_optlist
*mnt_new_optlist(void);
559 extern void mnt_ref_optlist(struct libmnt_optlist
*ls
);
560 extern void mnt_unref_optlist(struct libmnt_optlist
*ls
);
561 extern struct libmnt_optlist
*mnt_copy_optlist(struct libmnt_optlist
*ls
);
562 extern int mnt_optlist_is_empty(struct libmnt_optlist
*ls
);
563 extern unsigned int mnt_optlist_get_age(struct libmnt_optlist
*ls
);
564 extern int mnt_optlist_register_map(struct libmnt_optlist
*ls
, const struct libmnt_optmap
*map
);
565 extern int mnt_optlist_remove_opt(struct libmnt_optlist
*ls
, struct libmnt_opt
*opt
);
566 extern int mnt_optlist_remove_named(struct libmnt_optlist
*ls
, const char *name
,
567 const struct libmnt_optmap
*map
);
568 extern int mnt_optlist_remove_flags(struct libmnt_optlist
*ls
, unsigned long flags
,
569 const struct libmnt_optmap
*map
);
570 extern int mnt_optlist_next_opt(struct libmnt_optlist
*ls
,
571 struct libmnt_iter
*itr
, struct libmnt_opt
**opt
);
572 extern struct libmnt_opt
*mnt_optlist_get_opt(struct libmnt_optlist
*ls
,
573 unsigned long id
, const struct libmnt_optmap
*map
);
574 extern struct libmnt_opt
*mnt_optlist_get_named(struct libmnt_optlist
*ls
,
575 const char *name
, const struct libmnt_optmap
*map
);
576 extern int mnt_optlist_set_optstr(struct libmnt_optlist
*ls
, const char *optstr
,
577 const struct libmnt_optmap
*map
);
578 extern int mnt_optlist_append_optstr(struct libmnt_optlist
*ls
, const char *optstr
,
579 const struct libmnt_optmap
*map
);
580 extern int mnt_optlist_prepend_optstr(struct libmnt_optlist
*ls
, const char *optstr
,
581 const struct libmnt_optmap
*map
);
582 extern int mnt_optlist_append_flags(struct libmnt_optlist
*ls
, unsigned long flags
,
583 const struct libmnt_optmap
*map
);
584 extern int mnt_optlist_set_flags(struct libmnt_optlist
*ls
, unsigned long flags
,
585 const struct libmnt_optmap
*map
);
586 extern int mnt_optlist_insert_flags(struct libmnt_optlist
*ls
, unsigned long flags
,
587 const struct libmnt_optmap
*map
,
589 const struct libmnt_optmap
*after_map
);
590 /* "what" argument */
592 /* Default -- if @map specified then returns all options for the map, otherwise
593 * returns all options including uknonwn options, exclude external options */
594 MNT_OL_FLTR_DFLT
= 0,
595 /* Options as expected by mount.<type> helpers */
597 /* Options as expected in mtab */
599 /* All options -- include mapped, unknown and external options */
601 /* All unknown options -- exclude external (usually FS specific options) */
604 __MNT_OL_FLTR_COUNT
/* keep it last */
608 extern int mnt_optlist_get_flags(struct libmnt_optlist
*ls
, unsigned long *flags
,
609 const struct libmnt_optmap
*map
, unsigned int what
);
611 /* recursive status for mnt_optlist_get_attrs() */
613 #define MNT_OL_NOREC 2
615 extern int mnt_optlist_get_attrs(struct libmnt_optlist
*ls
, uint64_t *set
, uint64_t *clr
, int rec
);
617 extern int mnt_optlist_get_optstr(struct libmnt_optlist
*ol
, const char **optstr
,
618 const struct libmnt_optmap
*map
, unsigned int what
);
619 extern int mnt_optlist_strdup_optstr(struct libmnt_optlist
*ls
, char **optstr
,
620 const struct libmnt_optmap
*map
, unsigned int what
);
622 extern int mnt_optlist_get_propagation(struct libmnt_optlist
*ls
);
623 extern int mnt_optlist_is_propagation_only(struct libmnt_optlist
*ls
);
624 extern int mnt_optlist_is_remount(struct libmnt_optlist
*ls
);
625 extern int mnt_optlist_is_rpropagation(struct libmnt_optlist
*ls
);
626 extern int mnt_optlist_is_bind(struct libmnt_optlist
*ls
);
627 extern int mnt_optlist_is_rbind(struct libmnt_optlist
*ls
);
628 extern int mnt_optlist_is_move(struct libmnt_optlist
*ls
);
629 extern int mnt_optlist_is_rdonly(struct libmnt_optlist
*ls
);
630 extern int mnt_optlist_is_silent(struct libmnt_optlist
*ls
);
632 extern int mnt_optlist_merge_opts(struct libmnt_optlist
*ls
);
634 extern int mnt_opt_has_value(struct libmnt_opt
*opt
);
635 extern const char *mnt_opt_get_value(struct libmnt_opt
*opt
);
636 extern const char *mnt_opt_get_name(struct libmnt_opt
*opt
);
637 extern const struct libmnt_optmap
*mnt_opt_get_map(struct libmnt_opt
*opt
);
638 extern const struct libmnt_optmap
*mnt_opt_get_mapent(struct libmnt_opt
*opt
);
639 extern int mnt_opt_set_external(struct libmnt_opt
*opt
, int enable
);
640 extern int mnt_opt_set_value(struct libmnt_opt
*opt
, const char *str
);
641 extern int mnt_opt_set_u64value(struct libmnt_opt
*opt
, uint64_t num
);
642 extern int mnt_opt_set_quoted_value(struct libmnt_opt
*opt
, const char *str
);
643 extern int mnt_opt_is_external(struct libmnt_opt
*opt
);
644 extern int mnt_opt_is_sepnodata(struct libmnt_opt
*opt
);
645 extern int mnt_opt_value_with(struct libmnt_opt
*opt
, const char *str
);
648 extern int mnt_fs_follow_optlist(struct libmnt_fs
*fs
, struct libmnt_optlist
*ol
);
649 extern struct libmnt_fs
*mnt_copy_mtab_fs(struct libmnt_fs
*fs
);
650 extern int __mnt_fs_set_source_ptr(struct libmnt_fs
*fs
, char *source
)
651 __attribute__((nonnull(1)));
652 extern int __mnt_fs_set_fstype_ptr(struct libmnt_fs
*fs
, char *fstype
)
653 __attribute__((nonnull(1)));
654 extern int __mnt_fs_set_target_ptr(struct libmnt_fs
*fs
, char *tgt
)
655 __attribute__((nonnull(1)));
658 extern void mnt_context_syscall_save_status(struct libmnt_context
*cxt
,
659 const char *syscallname
, int success
);
660 extern void mnt_context_syscall_reset_status(struct libmnt_context
*cxt
);
662 extern struct libmnt_context
*mnt_copy_context(struct libmnt_context
*o
);
663 extern int mnt_context_utab_writable(struct libmnt_context
*cxt
);
664 extern const char *mnt_context_get_writable_tabpath(struct libmnt_context
*cxt
);
666 extern int mnt_context_within_helper(struct libmnt_context
*cxt
);
668 extern int mnt_context_get_mountinfo(struct libmnt_context
*cxt
, struct libmnt_table
**tb
);
669 extern int mnt_context_get_mountinfo_for_target(struct libmnt_context
*cxt
,
670 struct libmnt_table
**mountinfo
, const char *tgt
);
672 extern int mnt_context_prepare_srcpath(struct libmnt_context
*cxt
);
673 extern int mnt_context_guess_srcpath_fstype(struct libmnt_context
*cxt
, char **type
);
674 extern int mnt_context_guess_fstype(struct libmnt_context
*cxt
);
675 extern int mnt_context_prepare_helper(struct libmnt_context
*cxt
,
676 const char *name
, const char *type
);
677 extern int mnt_context_prepare_update(struct libmnt_context
*cxt
);
678 extern int mnt_context_merge_mflags(struct libmnt_context
*cxt
);
679 extern int mnt_context_update_tabs(struct libmnt_context
*cxt
);
681 extern int mnt_context_umount_setopt(struct libmnt_context
*cxt
, int c
, char *arg
);
682 extern int mnt_context_mount_setopt(struct libmnt_context
*cxt
, int c
, char *arg
);
684 extern void mnt_context_reset_mesgs(struct libmnt_context
*cxt
);
685 extern int mnt_context_append_mesg(struct libmnt_context
*cxt
, const char *msg
);
686 extern int mnt_context_sprintf_mesg(struct libmnt_context
*cxt
, const char *msg
, ...);
687 extern int mnt_context_read_mesgs(struct libmnt_context
*cxt
, int fd
);
689 extern int mnt_context_propagation_only(struct libmnt_context
*cxt
)
690 __attribute__((nonnull
));
692 extern int mnt_context_delete_loopdev(struct libmnt_context
*cxt
);
694 extern int mnt_fork_context(struct libmnt_context
*cxt
);
696 extern int mnt_context_set_tabfilter(struct libmnt_context
*cxt
,
697 int (*fltr
)(struct libmnt_fs
*, void *),
700 extern int mnt_context_get_generic_excode(int rc
, char *buf
, size_t bufsz
, const char *fmt
, ...)
701 __attribute__ ((__format__ (__printf__
, 4, 5)));
702 extern int mnt_context_get_mount_excode(struct libmnt_context
*cxt
, int mntrc
, char *buf
, size_t bufsz
);
703 extern int mnt_context_get_umount_excode(struct libmnt_context
*cxt
, int mntrc
, char *buf
, size_t bufsz
);
705 extern int mnt_context_has_template(struct libmnt_context
*cxt
);
706 extern int mnt_context_apply_template(struct libmnt_context
*cxt
);
707 extern int mnt_context_save_template(struct libmnt_context
*cxt
);
709 extern int mnt_context_apply_fs(struct libmnt_context
*cxt
, struct libmnt_fs
*fs
);
711 extern struct libmnt_optlist
*mnt_context_get_optlist(struct libmnt_context
*cxt
);
713 extern int mnt_context_is_xnocanonicalize(struct libmnt_context
*cxt
, const char *type
);
716 extern int mnt_update_emit_event(struct libmnt_update
*upd
);
717 extern int mnt_update_set_filename(struct libmnt_update
*upd
, const char *filename
);
718 extern int mnt_update_already_done(struct libmnt_update
*upd
);
719 extern int mnt_update_start(struct libmnt_update
*upd
);
720 extern int mnt_update_end(struct libmnt_update
*upd
);
724 extern uint64_t btrfs_get_default_subvol_id(const char *path
);
727 #ifdef USE_LIBMOUNT_MOUNTFD_SUPPORT
728 /* fsconfig/fsopen based stuff */
729 struct libmnt_sysapi
{
730 int fd_fs
; /* FD from fsopen() or fspick() */
731 int fd_tree
; /* FD from fsmount() or open_tree() */
733 char *subdir
; /* Linux >= 6.15 can directly open subdir;
734 * hook_subdir sets this variable */
736 unsigned int is_new_fs
: 1 ; /* fd_fs comes from fsopen() */
739 static inline struct libmnt_sysapi
*mnt_context_get_sysapi(struct libmnt_context
*cxt
)
741 return mnt_context_get_hookset_data(cxt
, &hookset_mount
);
744 int mnt_context_open_tree(struct libmnt_context
*cxt
, const char *path
, unsigned long mflg
);
748 #endif /* _LIBMOUNT_PRIVATE_H */