From 72f4a8685716a2ba75c436b46853d9bce8790634 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 25 Oct 2007 12:10:31 +0200 Subject: [PATCH] losetup: fix errno usage Signed-off-by: Karel Zak --- mount/lomount.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/mount/lomount.c b/mount/lomount.c index ace474cb..02548cc2 100644 --- a/mount/lomount.c +++ b/mount/lomount.c @@ -342,16 +342,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); @@ -386,7 +389,7 @@ set_loop(const char *device, const char *file, unsigned long long offset, return 0; } -int +int del_loop (const char *device) { int fd; -- 2.39.5