summaryrefslogtreecommitdiffstats
path: root/mount/lomount.c
diff options
context:
space:
mode:
authorKarel Zak2007-10-25 12:10:31 +0200
committerKarel Zak2007-10-25 21:50:59 +0200
commit0e7cd33ef2d2e6307c5f647f0434e54bcc0f62e2 (patch)
treef0e8830e0033903a2eaef869bd884db98ec41d9e /mount/lomount.c
parentrev: use warn() in errs.h (diff)
downloadkernel-qcow2-util-linux-0e7cd33ef2d2e6307c5f647f0434e54bcc0f62e2.tar.gz
kernel-qcow2-util-linux-0e7cd33ef2d2e6307c5f647f0434e54bcc0f62e2.tar.xz
kernel-qcow2-util-linux-0e7cd33ef2d2e6307c5f647f0434e54bcc0f62e2.zip
losetup: fix errno usage
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/lomount.c')
-rw-r--r--mount/lomount.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/mount/lomount.c b/mount/lomount.c
index 02b337f31..cea3aed44 100644
--- a/mount/lomount.c
+++ b/mount/lomount.c
@@ -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;