summaryrefslogtreecommitdiffstats
path: root/sys-utils/umount.c
diff options
context:
space:
mode:
authorKarel Zak2012-11-15 11:55:48 +0100
committerKarel Zak2012-11-15 11:55:48 +0100
commita8cc72dea0f4641f44fc48488f6eb7a86a9e309e (patch)
tree982e49c9bdf64f5751ff63487c779875b96ef08e /sys-utils/umount.c
parentlibblkid: remove obsolete tags from cache (diff)
downloadkernel-qcow2-util-linux-a8cc72dea0f4641f44fc48488f6eb7a86a9e309e.tar.gz
kernel-qcow2-util-linux-a8cc72dea0f4641f44fc48488f6eb7a86a9e309e.tar.xz
kernel-qcow2-util-linux-a8cc72dea0f4641f44fc48488f6eb7a86a9e309e.zip
umount: clean --recursive
- mark some options combinations mutually exclusive - reset libmount context before next umount (this is important!) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/umount.c')
-rw-r--r--sys-utils/umount.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index b0031026d..1cd2ebf67 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -289,6 +289,11 @@ static int umount_one(struct libmnt_context *cxt, const char *spec)
if (!spec)
return MOUNT_EX_SOFTWARE;
+ /* We have to reset the context to make this function and the
+ * context re-usable more than once (for example in --recursive)
+ */
+ mnt_reset_context(cxt);
+
if (mnt_context_set_target(cxt, spec))
err(MOUNT_EX_SYSERR, _("failed to set umount target"));
@@ -343,6 +348,8 @@ static int umount_recursive(struct libmnt_context *cxt, const char *spec)
tb = mnt_new_table();
if (!tb)
err(MOUNT_EX_SYSERR, _("libmount table allocation failed"));
+ mnt_table_set_parser_errcb(tb, table_parser_errcb);
+
/*
* Don't use mtab here. The recursive umount depends on child-parent
* relationship defined by mountinfo file.
@@ -397,6 +404,14 @@ int main(int argc, char **argv)
{ NULL, 0, 0, 0 }
};
+ static const ul_excl_t excl[] = { /* rows and cols in in ASCII order */
+ { 'R','a' }, /* recursive,all */
+ { 'O','R','t'}, /* options,recursive,types */
+ { 'R','r' }, /* recursive,read-only */
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
+
sanitize_env();
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -418,6 +433,8 @@ int main(int argc, char **argv)
if (mnt_context_is_restricted(cxt) && !strchr("hdilVv", c))
exit_non_root(option_to_longopt(c, longopts));
+ err_exclusive_options(c, longopts, excl, excl_st);
+
switch(c) {
case 'a':
all = 1;