summaryrefslogtreecommitdiffstats
path: root/sys-utils/umount.c
diff options
context:
space:
mode:
authorKarel Zak2013-09-27 10:06:44 +0200
committerKarel Zak2013-09-27 10:06:44 +0200
commit726f9fbf46c3e0427c47e7c68c69d4ae42191b71 (patch)
treeb7da613beac7c0c4eb8ca9958d2c6736a6f14ee0 /sys-utils/umount.c
parentlibmount: small cleanup in umount code (diff)
downloadkernel-qcow2-util-linux-726f9fbf46c3e0427c47e7c68c69d4ae42191b71.tar.gz
kernel-qcow2-util-linux-726f9fbf46c3e0427c47e7c68c69d4ae42191b71.tar.xz
kernel-qcow2-util-linux-726f9fbf46c3e0427c47e7c68c69d4ae42191b71.zip
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 <kzak@redhat.com>
Diffstat (limited to 'sys-utils/umount.c')
-rw-r--r--sys-utils/umount.c6
1 files changed, 6 insertions, 0 deletions
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) {