Top |
int | mnt_context_do_mount () |
int | mnt_context_finalize_mount () |
int | mnt_context_mount () |
int | mnt_context_next_mount () |
int | mnt_context_next_remount () |
int | mnt_context_prepare_mount () |
int
mnt_context_do_mount (struct libmnt_context *cxt
);
Call mount(2) or mount.type helper. Unnecessary for mnt_context_mount()
.
Note that this function could be called only once. If you want to mount
another source or target, then you have to call mnt_reset_context()
.
If you want to call mount(2) for the same source and target with different
mount flags or fstype, then call mnt_context_reset_status()
and then try
again mnt_context_do_mount()
.
WARNING: non-zero return code does not mean that mount(2) syscall or mount.type helper wasn't successfully called.
Check mnt_context_get_status()
after error! See mnt_context_mount()
for more
details about errors and warnings.
int
mnt_context_finalize_mount (struct libmnt_context *cxt
);
Mtab update, etc. Unnecessary for mnt_context_mount()
, but should be called
after mnt_context_do_mount()
. See also mnt_context_set_syscall_status()
.
int
mnt_context_mount (struct libmnt_context *cxt
);
High-level, mounts the filesystem by mount(2) or fork()
+exec(/sbin/mount.type).
This is similar to:
mnt_context_prepare_mount(cxt); mnt_context_do_mount(cxt); mnt_context_finalize_mount(cxt);
See also mnt_context_disable_helpers()
.
Note that this function should be called only once. If you want to mount with
different settings, then you have to call mnt_reset_context()
. It's NOT enough
to call mnt_context_reset_status()
. If you want to call this function more than
once, the whole context has to be reset.
WARNING: non-zero return code does not mean that mount(2) syscall or mount.type helper wasn't successfully called.
Always use mnt_context_get_status()
:
1 2 3 4 5 6 7 |
rc = mnt_context_mount(cxt); if (mnt_context_helper_executed(cxt)) return mnt_context_get_helper_status(cxt); if (rc == 0 && mnt_context_get_status(cxt) == 1) return MNT_EX_SUCCESS; return MNT_EX_FAIL; |
or mnt_context_get_excode()
to generate mount(8) compatible error
or warning message:
1 2 3 4 5 |
rc = mnt_context_mount(cxt); rc = mnt_context_get_excode(cxt, rc, buf, sizeof(buf)); if (buf) warnx(_("%s: %s"), mnt_context_get_target(cxt), buf); return rc; // MNT_EX_* |
int mnt_context_next_mount (struct libmnt_context *cxt
,struct libmnt_iter *itr
,struct libmnt_fs **fs
,int *mntrc
,int *ignored
);
This function tries to mount the next filesystem from fstab (as returned by
mnt_context_get_fstab()
). See also mnt_context_set_fstab()
.
You can filter out filesystems by:
mnt_context_set_options_pattern()
to simulate mount -a -O pattern
mnt_context_set_fstype_pattern()
to simulate mount -a -t pattern
If the filesystem is already mounted or does not match defined criteria,
then the mnt_context_next_mount()
function returns zero, but the ignored
is
non-zero. Note that the root filesystem and filesystems with "noauto" option
are always ignored.
If mount(2) syscall or mount.type helper failed, then the
mnt_context_next_mount()
function returns zero, but the mntrc
is non-zero.
Use also mnt_context_get_status()
to check if the filesystem was
successfully mounted.
See mnt_context_mount()
for more details about errors and warnings.
cxt |
context |
|
itr |
iterator |
|
fs |
returns the current filesystem |
|
mntrc |
returns the return code from |
|
ignored |
returns 1 for non-matching and 2 for already mounted filesystems |
int mnt_context_next_remount (struct libmnt_context *cxt
,struct libmnt_iter *itr
,struct libmnt_fs **fs
,int *mntrc
,int *ignored
);
This function tries to remount the next mounted filesystem (as returned by
mnt_context_get_mtab()
).
You can filter out filesystems by:
mnt_context_set_options_pattern()
to simulate mount -a -O pattern
mnt_context_set_fstype_pattern()
to simulate mount -a -t pattern
If the filesystem does not match defined criteria, then the
mnt_context_next_remount()
function returns zero, but the ignored
is
non-zero.
IMPORTANT -- the mount operation is performed in the current context.
The context is reset before the next mount (see mnt_reset_context()
).
The context setting related to the filesystem (e.g. mount options,
etc.) are protected.
If mount(2) syscall or mount.type helper failed, then the
mnt_context_next_mount()
function returns zero, but the mntrc
is non-zero.
Use also mnt_context_get_status()
to check if the filesystem was
successfully mounted.
See mnt_context_mount()
for more details about errors and warnings.
cxt |
context |
|
itr |
iterator |
|
fs |
returns the current filesystem |
|
mntrc |
returns the return code from |
|
ignored |
returns 1 for non-matching |
Since: 2.34
int
mnt_context_prepare_mount (struct libmnt_context *cxt
);
Prepare context for mounting, unnecessary for mnt_context_mount()
.