From 726f9fbf46c3e0427c47e7c68c69d4ae42191b71 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 27 Sep 2013 10:06:44 +0200 Subject: umount: provide more helpful error message non-root user on device that is not mounted: $ umount /mnt/flash umount: /mnt/flash: umount failed: Operation not permitted this is true, because we cannot evaluate permissions as there is no entry in mtab, but users expect something more helpful -- for example umount: /mnt/flash: not mounted References: https://bugs.archlinux.org/task/31647 Signed-off-by: Karel Zak --- sys-utils/umount.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sys-utils/umount.c') diff --git a/sys-utils/umount.c b/sys-utils/umount.c index b8e4b7fe6..47db5b480 100644 --- a/sys-utils/umount.c +++ b/sys-utils/umount.c @@ -198,6 +198,12 @@ static int mk_exit_code(struct libmnt_context *cxt, int rc) /* * libmount errors (extra library checks) */ + if (rc == -EPERM && !mnt_context_tab_applied(cxt)) { + /* failed to evaluate permissions because not found + * relevant entry in mtab */ + warnx(_("%s: not mounted"), tgt); + return MOUNT_EX_USAGE; + } return handle_generic_errors(rc, _("%s: umount failed"), tgt); } else if (mnt_context_get_syscall_errno(cxt) == 0) { -- cgit v1.2.3-55-g7522