summaryrefslogtreecommitdiffstats
path: root/shlibs/mount
diff options
context:
space:
mode:
authorKarel Zak2011-03-30 15:40:56 +0200
committerKarel Zak2011-03-30 15:40:56 +0200
commit4b658e0997ad63088782635acab0bca9bb46ad3d (patch)
treeb764b204c3faef26dd90da96199ed8b92b9c6ee7 /shlibs/mount
parentmount: add phelper= (diff)
downloadkernel-qcow2-util-linux-4b658e0997ad63088782635acab0bca9bb46ad3d.tar.gz
kernel-qcow2-util-linux-4b658e0997ad63088782635acab0bca9bb46ad3d.tar.xz
kernel-qcow2-util-linux-4b658e0997ad63088782635acab0bca9bb46ad3d.zip
libmount: add phelper= support
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount')
-rw-r--r--shlibs/mount/src/context_umount.c59
-rw-r--r--shlibs/mount/src/libmount.h.in1
-rw-r--r--shlibs/mount/src/optmap.c2
3 files changed, 45 insertions, 17 deletions
diff --git a/shlibs/mount/src/context_umount.c b/shlibs/mount/src/context_umount.c
index 0e69fe5f9..08b0fd46c 100644
--- a/shlibs/mount/src/context_umount.c
+++ b/shlibs/mount/src/context_umount.c
@@ -149,6 +149,32 @@ static int mnt_loopdev_associated_fs(const char *devname, struct libmnt_fs *fs)
return 0;
}
+static int prepare_helper_from_options(struct libmnt_context *cxt,
+ const char *name)
+{
+ char *suffix = NULL;
+ const char *opts;
+ size_t valsz;
+
+ if (cxt->flags & MNT_FL_NOHELPERS)
+ return 0;
+
+ opts = mnt_fs_get_user_options(cxt->fs);
+ if (!opts)
+ return 0;
+
+ if (mnt_optstr_get_option((char *) opts, name, &suffix, &valsz))
+ return 0;
+
+ suffix = strndup(suffix, valsz);
+ if (!suffix)
+ return -ENOMEM;
+
+ DBG(CXT, mnt_debug_h(cxt, "umount: umount.%s %s requested", suffix, name));
+
+ return mnt_context_prepare_helper(cxt, "umount", suffix);
+}
+
/*
* Note that cxt->fs contains relevant mtab entry!
*/
@@ -179,21 +205,10 @@ static int evaluate_permissions(struct libmnt_context *cxt)
goto eperm;
}
- if (!(cxt->flags & MNT_FL_NOHELPERS) &&
- (cxt->user_mountflags & MNT_MS_UHELPER)) {
-
- char *suffix = NULL;
- char *o = (char *) mnt_fs_get_user_options(cxt->fs);
- size_t valsz;
-
- rc = mnt_optstr_get_option(o, "uhelper", &suffix, &valsz);
- if (!rc) {
- suffix = strndup(suffix, valsz);
- if (!suffix)
- return -ENOMEM;
- rc = mnt_context_prepare_helper(cxt, "umount", suffix);
- }
- if (rc < 0)
+ if (cxt->user_mountflags & MNT_MS_UHELPER) {
+ /* on uhelper= mount option based helper */
+ rc = prepare_helper_from_options(cxt, "uhelper");
+ if (rc)
return rc;
if (cxt->helper)
return 0; /* we'll call /sbin/umount.<uhelper> */
@@ -566,8 +581,18 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
rc = evaluate_permissions(cxt);
if (!rc)
rc = mnt_context_prepare_target(cxt);
- if (!rc && !cxt->helper)
- rc = mnt_context_prepare_helper(cxt, "umount", NULL);
+
+ if (!rc && !cxt->helper) {
+
+ if (!cxt->restricted && (cxt->user_mountflags & MNT_MS_PHELPER))
+ /* on phelper= mount option based helper */
+ rc = prepare_helper_from_options(cxt, "phelper");
+
+ if (!rc && !cxt->helper)
+ /* on fstype based helper */
+ rc = mnt_context_prepare_helper(cxt, "umount", NULL);
+ }
+
/* TODO
if ((cxt->flags & MNT_FL_LOOPDEL) &&
(!mnt_is_loopdev(src) || mnt_loopdev_is_autoclear(src)))
diff --git a/shlibs/mount/src/libmount.h.in b/shlibs/mount/src/libmount.h.in
index d7e7a5172..613822468 100644
--- a/shlibs/mount/src/libmount.h.in
+++ b/shlibs/mount/src/libmount.h.in
@@ -439,6 +439,7 @@ extern int mnt_context_do_umount(struct libmnt_context *cxt);
#define MNT_MS_LOOP (1 << 9)
#define MNT_MS_NOFAIL (1 << 10)
#define MNT_MS_UHELPER (1 << 11)
+#define MNT_MS_PHELPER (1 << 12)
/*
* mount(2) MS_* masks (MNT_MAP_LINUX map)
diff --git a/shlibs/mount/src/optmap.c b/shlibs/mount/src/optmap.c
index 89ec101c3..4924e9ae3 100644
--- a/shlibs/mount/src/optmap.c
+++ b/shlibs/mount/src/optmap.c
@@ -155,6 +155,8 @@ static const struct libmnt_optmap userspace_opts_map[] =
{ "uhelper=", MNT_MS_UHELPER }, /* /sbin/umount.<helper> */
+ { "phelper=", MNT_MS_PHELPER }, /* /sbin/umount.<helper> */
+
{ NULL, 0, 0 }
};