diff options
author | Karel Zak | 2015-06-03 12:05:09 +0200 |
---|---|---|
committer | Karel Zak | 2015-06-03 12:05:09 +0200 |
commit | 362f5d203581e895005b91383ea7b1affafd8eba (patch) | |
tree | bc7460acff032e032c4f4c49f23a0c15d76b0d6b /sys-utils | |
parent | libmount: do not call umount helper on --fake (diff) | |
download | kernel-qcow2-util-linux-362f5d203581e895005b91383ea7b1affafd8eba.tar.gz kernel-qcow2-util-linux-362f5d203581e895005b91383ea7b1affafd8eba.tar.xz kernel-qcow2-util-linux-362f5d203581e895005b91383ea7b1affafd8eba.zip |
losetup: print more usable error message on failed -f
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1215370
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r-- | sys-utils/losetup.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c index c2bbd0d14..9201782ad 100644 --- a/sys-utils/losetup.c +++ b/sys-utils/losetup.c @@ -25,6 +25,7 @@ #include "optutils.h" #include "xalloc.h" #include "canonicalize.h" +#include "pathnames.h" enum { A_CREATE = 1, /* setup a new device */ @@ -697,9 +698,17 @@ int main(int argc, char **argv) break; case A_FIND_FREE: res = loopcxt_find_unused(&lc); - if (res) + if (res) { + int errsv = errno; + + if (access(_PATH_DEV_LOOPCTL, F_OK) == 0 && + access(_PATH_DEV_LOOPCTL, W_OK) != 0) + ; + else + errno = errsv; + warn(_("cannot find an unused loop device")); - else + } else printf("%s\n", loopcxt_get_device(&lc)); break; case A_SHOW: |