[PATCH] losetup: don't skip adding a new device if it already has a device node

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linux plans to deprecate the auto-creation of block devices based on
access to the devic node starting from kernel 5.18.  Without that feature
losetup will fail to create the loop device if a device node already
exists, but the loop device to back it in the kernel does not exist yet.
This is a scenario that should not happen in modern udev based
distributions, but apparently there still are various scripts around that
manually call the superflous mknod.

Change losetup to unconditionally call loopcxt_add_device when a specific
device node is specified on the command line.  If the loop device
already exists the LOOP_CTL_ADD ioctl will fail, but given that losetup
ignores the return value from loopcxt_add_device that failure has no
further effect.

Reported-by: Luis Chamberlain <mcgrof@xxxxxxxxxx>
Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 sys-utils/losetup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys-utils/losetup.c b/sys-utils/losetup.c
index c400cbf12..09c028b6b 100644
--- a/sys-utils/losetup.c
+++ b/sys-utils/losetup.c
@@ -522,7 +522,7 @@ static int create_loop(struct loopdev_cxt *lc,
 		}
 	}
 
-	if (hasdev && !is_loopdev(loopcxt_get_device(lc)))
+	if (hasdev)
 		loopcxt_add_device(lc);
 
 	/* losetup --noverlap /dev/loopN file.img */
-- 
2.30.2




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux