From: Karel Zak Date: Fri, 27 Sep 2013 08:06:44 +0000 (+0200) Subject: umount: provide more helpful error message X-Git-Tag: v2.24-rc1~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=726f9fbf46c3e0427c47e7c68c69d4ae42191b71;p=thirdparty%2Futil-linux.git 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 --- diff --git a/sys-utils/umount.c b/sys-utils/umount.c index b8e4b7fe67..47db5b4803 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) {