]> err.no Git - util-linux/commitdiff
losetup: missing EBUSY error hint message
authorKarel Zak <kzak@redhat.com>
Tue, 30 Sep 2008 10:49:58 +0000 (12:49 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 12 Dec 2008 12:03:35 +0000 (13:03 +0100)
old version:
 # losetup /dev/loop0 /foo.img
 # losetup /dev/loop0 /bar.img; echo $?
 2

new version:
 # losetup /dev/loop0 /foo.img
 # losetup /dev/loop0 /bar.img; echo $?
 losetup: /dev/loop0: device is busy
 2

Signed-off-by: Karel Zak <kzak@redhat.com>
mount/lomount.c

index c7fb12b76a8cd9c8149bff09ecfa510ff32500b6..d8ed55fac06f60e3688d7f2b7bca35bf7368a643 100644 (file)
@@ -633,6 +633,12 @@ digits_only(const char *s) {
        return 1;
 }
 
+/*
+ * return codes:
+ *     0       - success
+ *     1       - error
+ *     2       - error (EBUSY)
+ */
 int
 set_loop(const char *device, const char *file, unsigned long long offset,
         unsigned long long sizelimit, const char *encryption, int pfd, int *options) {
@@ -1026,11 +1032,16 @@ main(int argc, char **argv) {
                        }
                } while (find && res == 2);
 
-               if (verbose && res == 0)
-                       printf("Loop device is %s\n", device);
-
-               if (res == 0 && showdev && find)
-                       printf("%s\n", device);
+               if (device) {
+                       if (res == 2)
+                               error(_("%s: %s: device is busy"), progname, device);
+                       else if (res == 0) {
+                               if (verbose)
+                                       printf("Loop device is %s\n", device);
+                               if (showdev && find)
+                                       printf("%s\n", device);
+                       }
+               }
        }
        return res;
 }