]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: provide more helpful error message
authorKarel Zak <kzak@redhat.com>
Fri, 27 Sep 2013 08:06:44 +0000 (10:06 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 27 Sep 2013 08:06:44 +0000 (10:06 +0200)
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>
sys-utils/umount.c

index b8e4b7fe6733a3712291aecf63164d0ab2073540..47db5b4803ad09b3b93202d24b32d3cbd9d4f7bb 100644 (file)
@@ -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) {