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>
This commit is contained in:
parent
1f8590b56b
commit
a8cc72dea0
|
@ -289,6 +289,11 @@ static int umount_one(struct libmnt_context *cxt, const char *spec)
|
||||||
if (!spec)
|
if (!spec)
|
||||||
return MOUNT_EX_SOFTWARE;
|
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))
|
if (mnt_context_set_target(cxt, spec))
|
||||||
err(MOUNT_EX_SYSERR, _("failed to set umount target"));
|
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();
|
tb = mnt_new_table();
|
||||||
if (!tb)
|
if (!tb)
|
||||||
err(MOUNT_EX_SYSERR, _("libmount table allocation failed"));
|
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
|
* Don't use mtab here. The recursive umount depends on child-parent
|
||||||
* relationship defined by mountinfo file.
|
* relationship defined by mountinfo file.
|
||||||
|
@ -397,6 +404,14 @@ int main(int argc, char **argv)
|
||||||
{ NULL, 0, 0, 0 }
|
{ 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();
|
sanitize_env();
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||||
|
@ -418,6 +433,8 @@ int main(int argc, char **argv)
|
||||||
if (mnt_context_is_restricted(cxt) && !strchr("hdilVv", c))
|
if (mnt_context_is_restricted(cxt) && !strchr("hdilVv", c))
|
||||||
exit_non_root(option_to_longopt(c, longopts));
|
exit_non_root(option_to_longopt(c, longopts));
|
||||||
|
|
||||||
|
err_exclusive_options(c, longopts, excl, excl_st);
|
||||||
|
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'a':
|
case 'a':
|
||||||
all = 1;
|
all = 1;
|
||||||
|
|
Loading…
Reference in New Issue