]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
losetup: don't clear FD at EBUSY error in loopcxt_setup_device()
authorStanislav Brabec <sbrabec@suse.cz>
Tue, 27 May 2014 18:38:10 +0000 (20:38 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 28 May 2014 07:18:28 +0000 (09:18 +0200)
loopback lib clears the existing FD unconditionally at error in
loopcxt_setup_device().  This is done even after EBUSY, thus the second call
actually clears the previous setup wrongly.

Author:  Takashi Iwai <tiwai@suse.de>
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
lib/loopdev.c

index 1fbb000c42ab1c6ce7811c305319cce2169023fc..988f3d337aefa40a4ee81521a6f71c2ccd9c657e 100644 (file)
@@ -1294,7 +1294,7 @@ int loopcxt_setup_device(struct loopdev_cxt *lc)
 err:
        if (file_fd >= 0)
                close(file_fd);
-       if (dev_fd >= 0)
+       if (dev_fd >= 0 && rc != -EBUSY)
                ioctl(dev_fd, LOOP_CLR_FD, 0);
 
        DBG(lc, loopdev_debug("setup failed [rc=%d]", rc));