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>
/*
* 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) {