3
0
forked from pool/util-linux
util-linux/util-linux-2.14-mount_ignore_ENXIO_in_del_loop.patch

38 lines
1000 B
Diff

Index: util-linux-ng-2.14/mount/lomount.c
===================================================================
--- util-linux-ng-2.14.orig/mount/lomount.c 2008-06-25 11:35:27.000000000 +0200
+++ util-linux-ng-2.14/mount/lomount.c 2008-06-25 12:47:28.000000000 +0200
@@ -878,6 +878,7 @@ set_loop(const char *device, const char
int
del_loop (const char *device) {
int fd;
+ int res = 0;
if ((fd = open (device, O_RDONLY)) < 0) {
int errsv = errno;
@@ -886,10 +887,22 @@ del_loop (const char *device) {
return 1;
}
if (ioctl (fd, LOOP_CLR_FD, 0) < 0) {
- perror ("ioctl: LOOP_CLR_FD");
+ if (errno == ENXIO) {
+ /* ignore ENXIO, device has probably been
+ * auto-destructed */
+ if (verbose > 1)
+ printf(_("del_loop(%s): already deleted\n"),
+ device);
+ res = 0;
+ } else {
+ perror ("ioctl: LOOP_CLR_FD");
+ res = 1;
+ }
+
close(fd);
- return 1;
+ return res;
}
+
close (fd);
if (verbose > 1)
printf(_("del_loop(%s): success\n"), device);