]> err.no Git - util-linux/commitdiff
losetup: fix errno usage
authorKarel Zak <kzak@redhat.com>
Thu, 25 Oct 2007 10:10:31 +0000 (12:10 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 25 Oct 2007 19:50:59 +0000 (21:50 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/lomount.c

index 02b337f319c5094d6e672aa8b7beeabc73d18d1d..cea3aed4460567f87224dc274d1f5cac2becce86 100644 (file)
@@ -339,16 +339,19 @@ set_loop(const char *device, const char *file, unsigned long long offset,
        }
 
        if (ioctl(fd, LOOP_SET_FD, ffd) < 0) {
-               close(fd);
-               close(ffd);
+               int rc = 1;
+
                if (errno == EBUSY) {
                        if (verbose)
-                               printf(_("ioctl LOOP_SET_FD failed: %s\n"), strerror(errno));
-                       return 2;
-               } else {
+                               printf(_("ioctl LOOP_SET_FD failed: %s\n"),
+                                                       strerror(errno));
+                       rc = 2;
+               } else
                        perror("ioctl: LOOP_SET_FD");
-                       return 1;
-               }
+
+               close(fd);
+               close(ffd);
+               return rc;
        }
        close (ffd);
 
@@ -383,7 +386,7 @@ set_loop(const char *device, const char *file, unsigned long long offset,
        return 0;
 }
 
-int 
+int
 del_loop (const char *device) {
        int fd;