summaryrefslogtreecommitdiffstats
path: root/sys-utils/losetup.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys-utils/losetup.c')
-rw-r--r--sys-utils/losetup.c13
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: