mnt_context_is_fork
mnt_context_is_fs_mounted
mnt_context_is_lazy
+mnt_context_is_loopdel
+mnt_context_is_nocanonicalize
+mnt_context_is_nohelpers
mnt_context_is_nomtab
mnt_context_is_parent
mnt_context_is_rdonly_umount
* canonicalies paths when search in fstab and when prepare source and target paths
* for mount(2) syscall.
*
- * This fuction has effect to the private fstab instance only (see
- * mnt_context_set_fstab()). If you want to use an external fstab then you need
- * manage your private struct libmnt_cache (see mnt_table_set_cache(fstab, NULL).
+ * This fuction has effect to the private (within context) fstab instance only
+ * (see mnt_context_set_fstab()). If you want to use an external fstab then you
+ * need manage your private struct libmnt_cache (see mnt_table_set_cache(fstab,
+ * NULL).
*
* Returns: 0 on success, negative number in case of error.
*/
return set_flag(cxt, MNT_FL_NOCANONICALIZE, disable);
}
+/**
+ * mnt_context_is_nocanonicalize:
+ * @cxt: mount context
+ *
+ * Returns: 1 if no-canonicalize mode enabled or 0.
+ */
+int mnt_context_is_nocanonicalize(struct libmnt_context *cxt)
+{
+ return cxt && (cxt->flags & MNT_FL_NOCANONICALIZE) ? 1 : 0;
+}
+
/**
* mnt_context_enable_lazy:
* @cxt: mount context
return set_flag(cxt, MNT_FL_LAZY, enable);
}
+/**
+ * mnt_context_is_lazy:
+ * @cxt: mount context
+ *
+ * Returns: 1 if lazy umount is enabled or 0
+ */
+int mnt_context_is_lazy(struct libmnt_context *cxt)
+{
+ return cxt && (cxt->flags & MNT_FL_LAZY) ? 1 : 0;
+}
+
/**
* mnt_context_enable_fork:
* @cxt: mount context
}
/**
- * mnt_context_is_lazy:
+ * mnt_context_is_fork:
* @cxt: mount context
*
- * Returns: 1 if lazy umount is enabled or 0
+ * Returns: 1 if fork (mount -F) is enabled or 0
*/
-int mnt_context_is_lazy(struct libmnt_context *cxt)
+int mnt_context_is_fork(struct libmnt_context *cxt)
{
- return cxt && (cxt->flags & MNT_FL_LAZY) ? 1 : 0;
+ return cxt && (cxt->flags & MNT_FL_FORK) ? 1 : 0;
}
+/**
+ * mnt_context_is_parent:
+ * @cxt: mount context
+ *
+ * Return: 1 if mount -F enabled and the current context is parent, or 0
+ */
+int mnt_context_is_parent(struct libmnt_context *cxt)
+{
+ return mnt_context_is_fork(cxt) && cxt->pid == 0;
+}
+
+/**
+ * mnt_context_is_child:
+ * @cxt: mount context
+ *
+ * Return: 1 if mount -F enabled and the current context is child, or 0
+ */
+int mnt_context_is_child(struct libmnt_context *cxt)
+{
+ return !mnt_context_is_fork(cxt) && cxt->pid;
+}
/**
* mnt_context_enable_rdonly_umount:
return set_flag(cxt, MNT_FL_NOHELPERS, disable);
}
+/**
+ * mnt_context_is_nohelpers
+ * @cxt: mount context
+ *
+ * Returns: 1 if helpers are disabled (mount -i) or 0
+ */
+int mnt_context_is_nohelpers(struct libmnt_context *cxt)
+{
+ return cxt && (cxt->flags & MNT_FL_NOHELPERS) ? 1 : 0;
+}
+
+
/**
* mnt_context_enable_sloppy:
* @cxt: mount context
return set_flag(cxt, MNT_FL_LOOPDEL, enable);
}
+/**
+ * mnt_context_is_loopdel:
+ * @cxt: mount context
+ *
+ * Returns: 1 if loop device should be deleted after umount (umount -d) or 0.
+ */
+int mnt_context_is_loopdel(struct libmnt_context *cxt)
+{
+ return cxt && (cxt->flags & MNT_FL_LOOPDEL) ? 1 : 0;
+}
+
/**
* mnt_context_set_fs:
* @cxt: mount context
*/
struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt)
{
- if (!cxt || (cxt->flags & MNT_FL_NOCANONICALIZE))
+ if (!cxt || mnt_context_is_nocanonicalize(cxt))
return NULL;
if (!cxt->cache) {
* the lock. The mnt_update_* functions are able to allocate the lock
* only when mtab/utab update is really necessary.
*/
- if (!cxt || (cxt->flags & MNT_FL_NOMTAB))
+ if (!cxt || mnt_context_is_nomtab(cxt))
return NULL;
if (!cxt->lock) {
if (!type)
type = mnt_fs_get_fstype(cxt->fs);
- if ((cxt->flags & MNT_FL_NOHELPERS) || !type ||
- !strcmp(type, "none") || mnt_fs_is_swaparea(cxt->fs))
+ if (mnt_context_is_nohelpers(cxt)
+ || !type
+ || !strcmp(type, "none")
+ || mnt_fs_is_swaparea(cxt->fs))
return 0;
path = strtok_r(search_path, ":", &p);
if (cxt->action == MNT_ACT_UMOUNT && target && !strcmp(target, "/"))
/* Don't try to touch mtab if umounting root FS */
- cxt->flags |= MNT_FL_NOMTAB;
+ mnt_context_disable_mtab(cxt, TRUE);
- if (cxt->flags & MNT_FL_NOMTAB) {
+ if (mnt_context_is_nomtab(cxt)) {
DBG(CXT, mnt_debug_h(cxt, "skip update: NOMTAB flag"));
return 0;
}
assert(cxt);
- if (cxt->flags & MNT_FL_NOMTAB) {
+ if (mnt_context_is_nomtab(cxt)) {
DBG(CXT, mnt_debug_h(cxt, "don't update: NOMTAB flag"));
return 0;
}
case 0: /* child */
cxt->pid = getpid();
- cxt->flags &= ~MNT_FL_FORK;
+ mnt_context_enable_fork(cxt, FALSE);
DBG(CXT, mnt_debug_h(cxt, "child created"));
break;
return 0;
}
-int mnt_context_is_fork(struct libmnt_context *cxt)
-{
- return cxt && (cxt->flags & MNT_FL_FORK);
-}
-int mnt_context_is_parent(struct libmnt_context *cxt)
-{
- return mnt_context_is_fork(cxt) && cxt->pid == 0;
-}
-
-int mnt_context_is_child(struct libmnt_context *cxt)
-{
- return !mnt_context_is_fork(cxt) && cxt->pid;
-}
-
#ifdef TEST_PROGRAM
struct libmnt_lock *lock;
DBG(CXT, mnt_debug_h(cxt, "%smount(2) "
"[source=%s, target=%s, type=%s, "
" mountflags=0x%08lx, mountdata=%s]",
- (cxt->flags & MNT_FL_FAKE) ? "(FAKE) " : "",
+ mnt_context_is_fake(cxt) ? "(FAKE) " : "",
src, target, type,
flags, cxt->mountdata ? "yes" : "<none>"));
- if (cxt->flags & MNT_FL_FAKE)
+ if (mnt_context_is_fake(cxt))
cxt->syscall_status = 0;
else {
if (mount(src, target, type, flags, cxt->mountdata)) {
* another source or target than you have to call mnt_reset_context().
*
* If you want to call mount(2) for the same source and target with a diffrent
- * mount flags or fstype then you call mnt_context_reset_status() and then try
+ * 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
- * umount.type helper wasn't sucessfully called.
+ * mount.type helper wasn't sucessfully called.
*
* Check mnt_context_get_status() after error!
*
res = do_mount_by_pattern(cxt, cxt->fstype_pattern);
if (mnt_context_get_status(cxt)
- && !(cxt->flags & MNT_FL_FAKE)
+ && !mnt_context_is_fake(cxt)
&& !cxt->helper) {
/*
* Mounted by mount(2), do some post-mount checks
const char *opts;
size_t valsz;
- if (cxt->flags & MNT_FL_NOHELPERS)
+ if (mnt_context_is_nohelpers(cxt))
return 0;
opts = mnt_fs_get_user_options(cxt->fs);
args[i++] = cxt->helper; /* 1 */
args[i++] = mnt_fs_get_target(cxt->fs); /* 2 */
- if (cxt->flags & MNT_FL_NOMTAB)
+ if (mnt_context_is_nomtab(cxt))
args[i++] = "-n"; /* 3 */
- if (cxt->flags & MNT_FL_LAZY)
+ if (mnt_context_is_lazy(cxt))
args[i++] = "-l"; /* 4 */
- if (cxt->flags & MNT_FL_FORCE)
+ if (mnt_context_is_force(cxt))
args[i++] = "-f"; /* 5 */
- if (cxt->flags & MNT_FL_VERBOSE)
+ if (mnt_context_is_verbose(cxt))
args[i++] = "-v"; /* 6 */
- if (cxt->flags & MNT_FL_RDONLY_UMOUNT)
+ if (mnt_context_is_rdonly_umount(cxt))
args[i++] = "-r"; /* 7 */
if (type && !endswith(cxt->helper, type)) {
args[i++] = "-t"; /* 8 */
DBG(CXT, mnt_debug_h(cxt, "do umount"));
- if (cxt->restricted && !(cxt->flags & MNT_FL_FAKE)) {
+ if (cxt->restricted && !mnt_context_is_fake(cxt)) {
/*
* extra paranoa for non-root users
* -- chdir to the parent of the mountpoint and use NOFOLLOW
target = tgtbuf;
}
- if (cxt->flags & MNT_FL_LAZY)
+ if (mnt_context_is_lazy(cxt))
flags |= MNT_DETACH;
- else if (cxt->flags & MNT_FL_FORCE)
+ else if (mnt_context_is_force(cxt))
flags |= MNT_FORCE;
DBG(CXT, mnt_debug_h(cxt, "umount(2) [target='%s', flags=0x%08x]%s",
target, flags,
- cxt->flags & MNT_FL_FAKE ? " (FAKE)" : ""));
+ mnt_context_is_fake(cxt) ? " (FAKE)" : ""));
- if (cxt->flags & MNT_FL_FAKE)
+ if (mnt_context_is_fake(cxt))
rc = 0;
else {
rc = flags ? umount2(target, flags) : umount(target);
/*
* try remount read-only
*/
- if (rc < 0 && cxt->syscall_status == -EBUSY &&
- (cxt->flags & MNT_FL_RDONLY_UMOUNT) && src) {
+ if (rc < 0
+ && cxt->syscall_status == -EBUSY
+ && mnt_context_is_rdonly_umount(cxt)
+ && src) {
mnt_context_set_mflags(cxt, (cxt->mountflags |
MS_REMOUNT | MS_RDONLY));
- cxt->flags &= ~MNT_FL_LOOPDEL;
+ mnt_context_enable_loopdel(cxt, FALSE);
DBG(CXT, mnt_debug_h(cxt,
"umount(2) failed [errno=%d] -- trying to remount read-only",
rc = mnt_context_prepare_helper(cxt, "umount", NULL);
}
- if (!rc && (cxt->flags & MNT_FL_LOOPDEL) && cxt->fs) {
+ if (!rc && mnt_context_is_loopdel(cxt) && cxt->fs) {
const char *src = mnt_fs_get_srcpath(cxt->fs);
if (src && (!is_loopdev(src) || loopdev_is_autoclear(src)))
- cxt->flags &= ~MNT_FL_LOOPDEL;
+ mnt_context_enable_loopdel(cxt, FALSE);
}
if (rc) {
if (rc)
return rc;
- if (mnt_context_get_status(cxt) && !(cxt->flags & MNT_FL_FAKE)) {
+ if (mnt_context_get_status(cxt) && !mnt_context_is_fake(cxt)) {
/*
* Umounted, do some post-umount operations
* - remove loopdev
* - refresh in-memory mtab stuff if remount rather than
* umount has been performed
*/
- if ((cxt->flags & MNT_FL_LOOPDEL)
+ if (mnt_context_is_loopdel(cxt)
&& !(cxt->mountflags & MS_REMOUNT))
rc = mnt_context_delete_loopdev(cxt);
- if (!(cxt->flags & MNT_FL_NOMTAB)
+ if (!mnt_context_is_nomtab(cxt)
&& mnt_context_get_status(cxt)
&& !cxt->helper
- && (cxt->flags & MNT_FL_RDONLY_UMOUNT)
+ && mnt_context_is_rdonly_umount(cxt)
&& (cxt->mountflags & MS_REMOUNT)) {
/* use "remount" instead of "umount" in /etc/mtab */
extern int mnt_context_is_nomtab(struct libmnt_context *cxt);
extern int mnt_context_is_force(struct libmnt_context *cxt);
extern int mnt_context_is_verbose(struct libmnt_context *cxt);
+extern int mnt_context_is_loopdel(struct libmnt_context *cxt);
+extern int mnt_context_is_nohelpers(struct libmnt_context *cxt);
+extern int mnt_context_is_nocanonicalize(struct libmnt_context *cxt);
extern int mnt_context_is_fork(struct libmnt_context *cxt);
extern int mnt_context_is_parent(struct libmnt_context *cxt);
global:
mnt_fs_streq_target;
mnt_fs_streq_srcpath;
+ mnt_context_is_loopdel;
+ mnt_context_is_nocanonicalize;
+ mnt_context_is_nohelpers;
} MOUNT_2.21;