libmount Reference Manual | ||||
---|---|---|---|---|
Top | Description |
struct libmnt_context; void mnt_free_context (struct libmnt_context *cxt
); struct libmnt_context * mnt_new_context (void
); int mnt_reset_context (struct libmnt_context *cxt
); int mnt_context_append_options (struct libmnt_context *cxt
,const char *optstr
); int mnt_context_apply_fstab (struct libmnt_context *cxt
); int mnt_context_disable_canonicalize (struct libmnt_context *cxt
,int disable
); int mnt_context_disable_helpers (struct libmnt_context *cxt
,int disable
); int mnt_context_disable_mtab (struct libmnt_context *cxt
,int disable
); int mnt_context_disable_swapmatch (struct libmnt_context *cxt
,int disable
); int mnt_context_enable_fake (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_force (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_fork (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_lazy (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_loopdel (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_rdonly_umount (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_sloppy (struct libmnt_context *cxt
,int enable
); int mnt_context_enable_verbose (struct libmnt_context *cxt
,int enable
); struct libmnt_cache * mnt_context_get_cache (struct libmnt_context *cxt
); struct libmnt_fs * mnt_context_get_fs (struct libmnt_context *cxt
); int mnt_context_get_fstab (struct libmnt_context *cxt
,struct libmnt_table **tb
); void * mnt_context_get_fstab_userdata (struct libmnt_context *cxt
); const char * mnt_context_get_fstype (struct libmnt_context *cxt
); void * mnt_context_get_fs_userdata (struct libmnt_context *cxt
); int mnt_context_get_helper_status (struct libmnt_context *cxt
); struct libmnt_lock * mnt_context_get_lock (struct libmnt_context *cxt
); int mnt_context_get_mflags (struct libmnt_context *cxt
,unsigned long *flags
); int mnt_context_get_mtab (struct libmnt_context *cxt
,struct libmnt_table **tb
); void * mnt_context_get_mtab_userdata (struct libmnt_context *cxt
); const char * mnt_context_get_options (struct libmnt_context *cxt
); int mnt_context_get_optsmode (struct libmnt_context *cxt
); const char * mnt_context_get_source (struct libmnt_context *cxt
); int mnt_context_get_status (struct libmnt_context *cxt
); int mnt_context_get_syscall_errno (struct libmnt_context *cxt
); int mnt_context_get_table (struct libmnt_context *cxt
,const char *filename
,struct libmnt_table **tb
); const char * mnt_context_get_target (struct libmnt_context *cxt
); int mnt_context_get_user_mflags (struct libmnt_context *cxt
,unsigned long *flags
); int mnt_context_helper_executed (struct libmnt_context *cxt
); int mnt_context_helper_setopt (struct libmnt_context *cxt
,int c
,char *arg
); int mnt_context_init_helper (struct libmnt_context *cxt
,int action
,int flags
); int mnt_context_is_child (struct libmnt_context *cxt
); int mnt_context_is_fake (struct libmnt_context *cxt
); int mnt_context_is_force (struct libmnt_context *cxt
); int mnt_context_is_fork (struct libmnt_context *cxt
); int mnt_context_is_fs_mounted (struct libmnt_context *cxt
,struct libmnt_fs *fs
,int *mounted
); int mnt_context_is_lazy (struct libmnt_context *cxt
); int mnt_context_is_loopdel (struct libmnt_context *cxt
); int mnt_context_is_nocanonicalize (struct libmnt_context *cxt
); int mnt_context_is_nohelpers (struct libmnt_context *cxt
); int mnt_context_is_nomtab (struct libmnt_context *cxt
); int mnt_context_is_parent (struct libmnt_context *cxt
); int mnt_context_is_rdonly_umount (struct libmnt_context *cxt
); int mnt_context_is_restricted (struct libmnt_context *cxt
); int mnt_context_is_sloppy (struct libmnt_context *cxt
); int mnt_context_is_swapmatch (struct libmnt_context *cxt
); int mnt_context_is_verbose (struct libmnt_context *cxt
); int mnt_context_reset_status (struct libmnt_context *cxt
); int mnt_context_set_cache (struct libmnt_context *cxt
,struct libmnt_cache *cache
); int mnt_context_set_fs (struct libmnt_context *cxt
,struct libmnt_fs *fs
); int mnt_context_set_fstab (struct libmnt_context *cxt
,struct libmnt_table *tb
); int mnt_context_set_fstype (struct libmnt_context *cxt
,const char *fstype
); int mnt_context_set_fstype_pattern (struct libmnt_context *cxt
,const char *pattern
); int mnt_context_set_mflags (struct libmnt_context *cxt
,unsigned long flags
); int mnt_context_set_mountdata (struct libmnt_context *cxt
,void *data
); int mnt_context_set_options (struct libmnt_context *cxt
,const char *optstr
); int mnt_context_set_options_pattern (struct libmnt_context *cxt
,const char *pattern
); int mnt_context_set_optsmode (struct libmnt_context *cxt
,int mode
); int mnt_context_set_passwd_cb (struct libmnt_context *cxt
,char* (*get) (struct libmnt_context *)
,void (*release) (struct libmnt_context *, char *)
); int mnt_context_set_source (struct libmnt_context *cxt
,const char *source
); int mnt_context_set_syscall_status (struct libmnt_context *cxt
,int status
); int mnt_context_set_tables_errcb (struct libmnt_context *cxt
,int (*cb) (struct libmnt_table *tb, const char *filename, int line)
); int mnt_context_set_target (struct libmnt_context *cxt
,const char *target
); int mnt_context_set_user_mflags (struct libmnt_context *cxt
,unsigned long flags
); int mnt_context_strerror (struct libmnt_context *cxt
,char *buf
,size_t bufsiz
); int mnt_context_syscall_called (struct libmnt_context *cxt
); int mnt_context_tab_applied (struct libmnt_context *cxt
); int mnt_context_wait_for_children (struct libmnt_context *cxt
,int *nchildren
,int *nerrs
); #define MNT_ERR_AMBIFS #define MNT_ERR_APPLYFLAGS #define MNT_ERR_LOOPDEV #define MNT_ERR_MOUNTOPT #define MNT_ERR_NOFSTAB #define MNT_ERR_NOFSTYPE #define MNT_ERR_NOSOURCE
1 2 3 4 5 6 7 8 9 |
struct libmnt_context *cxt = mnt_new_context(); mnt_context_set_options(cxt, "aaa,bbb,ccc=CCC"); mnt_context_set_mflags(cxt, MS_NOATIME|MS_NOEXEC); mnt_context_set_target(cxt, "/mnt/foo"); if (!mnt_context_mount(cxt)) printf("successfully mounted\n"); mnt_free_context(cxt); |
This code is similar to:
mount -o aaa,bbb,ccc=CCC,noatime,noexec /mnt/foo
void mnt_free_context (struct libmnt_context *cxt
);
Deallocates context struct.
|
mount context |
struct libmnt_context * mnt_new_context (void
);
Returns : |
newly allocated mount context |
int mnt_reset_context (struct libmnt_context *cxt
);
Resets all information in the context that is directly related to the latest mount (spec, source, target, mount options, ...).
The match patterns, cached fstab, cached canonicalized paths and tags and [e]uid are not reset. You have to use
mnt_context_set_fstab(cxt, NULL); mnt_context_set_cache(cxt, NULL); mnt_context_set_fstype_pattern(cxt, NULL); mnt_context_set_options_pattern(cxt, NULL);
to reset this stuff.
|
mount context |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_append_options (struct libmnt_context *cxt
,const char *optstr
);
|
mount context |
|
comma delimited mount options |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_apply_fstab (struct libmnt_context *cxt
);
This function is optional.
|
mount context |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_disable_canonicalize (struct libmnt_context *cxt
,int disable
);
Enable/disable paths canonicalization and tags evaluation. The libmount context canonicalizes paths when searching in fstab and when preparing source and target paths for mount(2) syscall.
This fuction has an effect on the private (within context) fstab instance only
(see mnt_context_set_fstab()
). If you want to use an external fstab then you
need to manage your private struct libmnt_cache (see mnt_table_set_cache(fstab,
NULL).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_disable_helpers (struct libmnt_context *cxt
,int disable
);
Enable/disable /sbin/[u]mount.* helpers (see mount(8) man page, option -i).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_disable_mtab (struct libmnt_context *cxt
,int disable
);
Disable/enable mtab update (see mount(8) man page, option -n).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_disable_swapmatch (struct libmnt_context *cxt
,int disable
);
Disable/enable swap between source and target for mount(8) if only one path is specified.
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_fake (struct libmnt_context *cxt
,int enable
);
Enable/disable fake mounting (see mount(8) man page, option -f).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_force (struct libmnt_context *cxt
,int enable
);
Enable/disable force umounting (see umount(8) man page, option -f).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_fork (struct libmnt_context *cxt
,int enable
);
Enable/disable fork(2) call in mnt_context_next_mount()
(see mount(8) man
page, option -F).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_lazy (struct libmnt_context *cxt
,int enable
);
Enable/disable lazy umount (see umount(8) man page, option -l).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_loopdel (struct libmnt_context *cxt
,int enable
);
Enable/disable the loop delete (destroy) after umount (see umount(8), option -d)
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_rdonly_umount (struct libmnt_context *cxt
,int enable
);
Enable/disable read-only remount on failed umount(2) (see umount(8) man page, option -r).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_sloppy (struct libmnt_context *cxt
,int enable
);
Set/unset sloppy mounting (see mount(8) man page, option -s).
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_enable_verbose (struct libmnt_context *cxt
,int enable
);
Enable/disable verbose output (TODO: not implemented yet)
|
mount context |
|
TRUE or FALSE |
Returns : |
0 on success, negative number in case of error. |
struct libmnt_cache * mnt_context_get_cache (struct libmnt_context *cxt
);
See also mnt_context_set_cache()
.
|
mount context |
Returns : |
pointer to cache or NULL if canonicalization is disabled. |
struct libmnt_fs * mnt_context_get_fs (struct libmnt_context *cxt
);
The FS contains the basic description of mountpoint, fs type and so on. Note that the FS is modified by mnt_context_set_{source,target,options,fstype} functions.
|
mount context |
Returns : |
pointer to FS description or NULL in case of a calloc() error. |
int mnt_context_get_fstab (struct libmnt_context *cxt
,struct libmnt_table **tb
);
See also mnt_table_parse_fstab()
for more details about fstab.
|
mount context |
|
returns fstab |
Returns : |
0 on success, negative number in case of error. |
void * mnt_context_get_fstab_userdata (struct libmnt_context *cxt
);
|
mount context |
Returns : |
pointer to userdata or NULL. |
const char * mnt_context_get_fstype (struct libmnt_context *cxt
);
|
mount context |
Returns : |
pointer or NULL in case of error or if not set. |
void * mnt_context_get_fs_userdata (struct libmnt_context *cxt
);
|
mount context |
Returns : |
pointer to userdata or NULL. |
int mnt_context_get_helper_status (struct libmnt_context *cxt
);
Return: mount.type helper exit status, result is reliable only if
mnt_context_helper_executed()
returns 1.
|
mount context |
struct libmnt_lock * mnt_context_get_lock (struct libmnt_context *cxt
);
The libmount applications don't have to care about mtab locking, but with a small exception: the application has to be able to remove the lock file when interrupted by signal or signals have to be ignored when the lock is locked.
The default behavior is to ignore all signals (except SIGALRM and SIGTRAP for mtab udate) when the lock is locked. If this behavior is unacceptable, then use:
lc = mnt_context_get_lock(cxt); if (lc) mnt_lock_block_signals(lc, FALSE);
and don't forget to call mnt_unlock_file(lc) before exit.
|
mount context |
Returns : |
pointer to lock struct or NULL. |
int mnt_context_get_mflags (struct libmnt_context *cxt
,unsigned long *flags
);
Converts mount options string to MS_* flags and bitewise-OR the result with
the already defined flags (see mnt_context_set_mflags()
).
|
mount context |
|
returns MS_* mount flags |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_get_mtab (struct libmnt_context *cxt
,struct libmnt_table **tb
);
See also mnt_table_parse_mtab()
for more details about mtab/mountinfo. The
result will be deallocated by mnt_free_context(cxt
).
|
mount context |
|
returns mtab |
Returns : |
0 on success, negative number in case of error. |
void * mnt_context_get_mtab_userdata (struct libmnt_context *cxt
);
|
mount context |
Returns : |
pointer to userdata or NULL. |
const char * mnt_context_get_options (struct libmnt_context *cxt
);
This function returns mount options set by mnt_context_set_options()
or
mnt_context_append_options()
.
Note that *after* mnt_context_prepare_mount()
, the mount options string
may also include options set by mnt_context_set_mflags()
or other options
generated by this library.
|
mount context |
Returns : |
pointer or NULL |
int mnt_context_get_optsmode (struct libmnt_context *cxt
);
|
mount context |
Returns : |
MNT_OMODE_* mask or zero. |
const char * mnt_context_get_source (struct libmnt_context *cxt
);
|
mount context |
Returns : |
returns pointer or NULL in case of error or if not set. |
int mnt_context_get_status (struct libmnt_context *cxt
);
Global libmount status.
The real exit code of the mount.type helper has to be tested by
mnt_context_get_helper_status()
. The mnt_context_get_status()
only informs
that exec()
has been successful.
|
mount context |
Returns : |
1 if mount.type or mount(2) syscall has been successfully called. |
int mnt_context_get_syscall_errno (struct libmnt_context *cxt
);
The result from this function is reliable only if
mnt_context_syscall_called()
returns 1.
|
mount context |
Returns : |
mount(2) errno if the syscall failed or 0. |
int mnt_context_get_table (struct libmnt_context *cxt
,const char *filename
,struct libmnt_table **tb
);
This function allocates a new table and parses the file
. The parser error
callback and cache for tags and paths is set according to the cxt
setting.
See also mnt_table_parse_file()
.
It's strongly recommended to use the mnt_context_get_mtab()
and
mnt_context_get_fstab()
functions for mtab and fstab files. This function
does not care about LIBMOUNT_* env.variables and does not merge userspace
options.
The result will NOT be deallocated by mnt_free_context(cxt
).
|
mount context |
|
e.g. /proc/self/mountinfo |
|
returns the table |
Returns : |
0 on success, negative number in case of error. |
const char * mnt_context_get_target (struct libmnt_context *cxt
);
|
mount context |
Returns : |
returns pointer or NULL in case of error or if not set. |
int mnt_context_get_user_mflags (struct libmnt_context *cxt
,unsigned long *flags
);
Converts mount options string to MNT_MS_* flags and bitewise-OR the result
with the already defined flags (see mnt_context_set_user_mflags()
).
|
mount context |
|
returns mount flags |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_helper_executed (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if mount.type helper has been executed, or 0. |
int mnt_context_helper_setopt (struct libmnt_context *cxt
,int c
,char *arg
);
This function applies the [u]mount.type command line option (for example parsed
by getopt or getopt_long) to cxt
. All unknown options are ignored and
then 1 is returned.
|
context |
|
getopt() result |
|
getopt() optarg |
Returns : |
negative number on error, 1 if c is unknown option, 0 on success. |
int mnt_context_init_helper (struct libmnt_context *cxt
,int action
,int flags
);
This function informs libmount that used from [u]mount.type helper.
The function also calls mnt_context_disable_helpers()
to avoid recursive
mount.type helpers calling. It you really want to call another
mount.type helper from your helper, then you have to explicitly enable this
feature by:
mnt_context_disable_helpers(cxt, FALSE);
|
mount context |
|
MNT_ACT_{UMOUNT,MOUNT} |
|
not used now |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_is_child (struct libmnt_context *cxt
);
Return: 1 f the current context is child, or 0
|
mount context |
int mnt_context_is_fake (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if fake flag is enabled or 0 |
int mnt_context_is_force (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if force umounting flag is enabled or 0 |
int mnt_context_is_fork (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if fork (mount -F) is enabled or 0 |
int mnt_context_is_fs_mounted (struct libmnt_context *cxt
,struct libmnt_fs *fs
,int *mounted
);
Please, read the mnt_table_is_fs_mounted()
description!
|
context |
|
filesystem |
|
returns 1 for mounted and 0 for non-mounted filesystems |
Returns : |
0 on success and negative number in case of error. |
int mnt_context_is_lazy (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if lazy umount is enabled or 0 |
int mnt_context_is_loopdel (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if loop device should be deleted after umount (umount -d) or 0. |
int mnt_context_is_nocanonicalize (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if no-canonicalize mode is enabled or 0. |
int mnt_context_is_nohelpers (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if helpers are disabled (mount -i) or 0 |
int mnt_context_is_nomtab (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if no-mtab is enabled or 0 |
int mnt_context_is_parent (struct libmnt_context *cxt
);
Return: 1 if mount -F enabled and the current context is parent, or 0
|
mount context |
int mnt_context_is_rdonly_umount (struct libmnt_context *cxt
);
See also mnt_context_enable_rdonly_umount()
and umount(8) man page,
option -r.
|
mount context |
Returns : |
1 if read-only remount failed umount(2) is enables or 0 |
int mnt_context_is_restricted (struct libmnt_context *cxt
);
|
mount context |
Returns : |
0 for an unrestricted mount (user is root), or 1 for non-root mounts |
int mnt_context_is_sloppy (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if sloppy flag is enabled or 0 |
int mnt_context_is_swapmatch (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if swap between source and target is allowed (default is 1) or 0. |
int mnt_context_is_verbose (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if verbose flag is enabled or 0 |
int mnt_context_reset_status (struct libmnt_context *cxt
);
Resets mount(2) and mount.type statuses, so mnt_context_do_mount()
or
mnt_context_do_umount()
could be again called with the same settings.
BE CAREFUL -- after this soft reset the libmount will NOT parse mount options, evaluate permissions or apply stuff from fstab.
|
context |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_cache (struct libmnt_context *cxt
,struct libmnt_cache *cache
);
The mount context maintains a private struct libmnt_cache by default. This function allows to overwrite the private cache with an external instance. This function increments cache reference counter.
If the cache
argument is NULL, then the current cache instance is reset.
This function apply the cache to fstab and mtab instances (if already
exists).
The old cache instance reference counter is de-incremented.
|
mount context |
|
cache instance or nULL |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_fs (struct libmnt_context *cxt
,struct libmnt_fs *fs
);
The mount context uses private fs
by default. This function allows to
overwrite the private fs
with an external instance. This function
increments fs
reference counter (and deincrement reference counter of the
old fs).
The fs
will be modified by mnt_context_set_{source,target,options,fstype}
functions, If the fs
is NULL, then all current FS specific settings (source,
target, etc., exclude spec) are reset.
|
mount context |
|
filesystem description |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_fstab (struct libmnt_context *cxt
,struct libmnt_table *tb
);
The mount context reads /etc/fstab to the private struct libmnt_table by default. This function allows to overwrite the private fstab with an external instance.
This function modify the tb
reference counter. This function does not set
the cache for the tb
. You have to explicitly call mnt_table_set_cache(tb,
mnt_context_get_cache(cxt));
The fstab is used read-only and is not modified, it should be possible to share the fstab between more mount contexts (TODO: test it.)
If the tb
argument is NULL, then the current private fstab instance is
reset.
|
mount context |
|
fstab |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_fstype (struct libmnt_context *cxt
,const char *fstype
);
Note that the fstype
has to be a FS type. For patterns with
comma-separated list of filesystems or for the "nofs" notation, use
mnt_context_set_fstype_pattern()
.
|
mount context |
|
filesystem type |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_fstype_pattern (struct libmnt_context *cxt
,const char *pattern
);
See mount(8), option -t.
|
mount context |
|
FS name pattern (or NULL to reset the current setting) |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_mflags (struct libmnt_context *cxt
,unsigned long flags
);
Sets mount flags (see mount(2) man page).
Note that mount context allows to define mount options by mount flags. It means you can for example use
mnt_context_set_mflags(cxt, MS_NOEXEC | MS_NOSUID);
rather than
mnt_context_set_options(cxt, "noexec,nosuid");
both of these calls have the same effect.
|
mount context |
|
mount(2) flags (MS_* flags) |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_mountdata (struct libmnt_context *cxt
,void *data
);
The mount context generates mountdata from mount options by default. This
function allows to overwrite this behavior, and data
will be used instead
of mount options.
The libmount does not deallocate the data by mnt_free_context()
. Note that
NULL is also valid mount data.
|
mount context |
|
mount(2) data |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_options (struct libmnt_context *cxt
,const char *optstr
);
|
mount context |
|
comma delimited mount options |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_options_pattern (struct libmnt_context *cxt
,const char *pattern
);
See mount(8), option -O.
|
mount context |
|
options pattern (or NULL to reset the current setting) |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_optsmode (struct libmnt_context *cxt
,int mode
);
Controls how to use mount optionssource and target paths from fstab/mtab.
MNT_OMODE_IGNORE
: ignore mtab/fstab options
MNT_OMODE_APPEND
: append mtab/fstab options to existing options
MNT_OMODE_PREPEND
: prepend mtab/fstab options to existing options
MNT_OMODE_REPLACE
: replace existing options with options from mtab/fstab
MNT_OMODE_FORCE
: always read mtab/fstab (although source and target are defined)
MNT_OMODE_FSTAB
: read from fstab
MNT_OMODE_MTAB
: read from mtab if fstab not enabled or failed
MNT_OMODE_NOTAB
: do not read fstab/mtab at all
MNT_OMODE_AUTO
: default mode (MNT_OMODE_PREPEND | MNT_OMODE_FSTAB | MNT_OMODE_MTAB)
MNT_OMODE_USER
: default for non-root users (MNT_OMODE_REPLACE | MNT_OMODE_FORCE | MNT_OMODE_FSTAB)
Notes:
MNT_OMODE_USER is always used if mount context is in restricted mode
MNT_OMODE_AUTO is used if nothing else is defined
the flags are evaluated in this order: MNT_OMODE_NOTAB, MNT_OMODE_FORCE, MNT_OMODE_FSTAB, MNT_OMODE_MTAB and then the mount options from fstab/mtab are set according to MNT_OMODE_{IGNORE,APPEND,PREPAND,REPLACE}
|
mount context |
|
MNT_OMODE_* flags |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_passwd_cb (struct libmnt_context *cxt
,char* (*get) (struct libmnt_context *)
,void (*release) (struct libmnt_context *, char *)
);
Sets callbacks for encryption password (e.g encrypted loopdev). This function is deprecated (encrypted loops are no longer supported).
|
mount context |
|
callback to get password |
|
callback to release (delallocate) password |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_source (struct libmnt_context *cxt
,const char *source
);
Note that libmount does not interpret "nofail" (MNT_MS_NOFAIL) mount option. The real return code is always returned, when the device does not exist then it's usually MNT_ERR_NOSOURCE from libmount or ENOENT, ENOTDIR, ENOTBLK, ENXIO from moun(2).
|
mount context |
|
mount source (device, directory, UUID, LABEL, ...) |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_syscall_status (struct libmnt_context *cxt
,int status
);
The status
should be 0 on success, or negative number on error (-errno).
This function should only be used if the [u]mount(2) syscall is NOT called by libmount code.
|
mount context |
|
mount(2) status |
Returns : |
0 or negative number in case of error. |
int mnt_context_set_tables_errcb (struct libmnt_context *cxt
,int (*cb) (struct libmnt_table *tb, const char *filename, int line)
);
The error callback is used for all tab files (e.g. mtab, fstab) parsed within the context.
See also mnt_context_get_mtab()
,
mnt_context_get_fstab()
,
mnt_table_set_parser_errcb()
.
|
mount context |
|
pointer to callback function |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_target (struct libmnt_context *cxt
,const char *target
);
|
mount context |
|
mountpoint |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_set_user_mflags (struct libmnt_context *cxt
,unsigned long flags
);
Sets userspace mount flags.
See also notes for mnt_context_set_mflags()
.
|
mount context |
|
mount(2) flags (MNT_MS_* flags, e.g. MNT_MS_LOOP) |
Returns : |
0 on success, negative number in case of error. |
int mnt_context_strerror (struct libmnt_context *cxt
,char *buf
,size_t bufsiz
);
Not implemented yet.
|
context |
|
buffer |
|
size of the buffer |
Returns : |
0 or negative number in case of error. |
int mnt_context_syscall_called (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if mount(2) syscall has been called, or 0. |
int mnt_context_tab_applied (struct libmnt_context *cxt
);
|
mount context |
Returns : |
1 if fstab (or mtab) has been applied to the context, or 0. |
int mnt_context_wait_for_children (struct libmnt_context *cxt
,int *nchildren
,int *nerrs
);