On Tue, Oct 31, 2023 at 06:34:03PM +0100, Dragan Simic wrote: > On 2023-10-25 22:36, Junxiao Bi wrote: > > If a /dev/loopX is lost because someone might have removed it by > > mistake, > > future losetup operations on that loop device will fail. > > For examples, following cmds will fail when loop device file is lost. > > - "losetup -d $loop_device" > > - "losetup -f $file" or "mount $file $dev" > > > > Since /sysfs still have the loop device intact, detect that and report > > detailed log message to guide user to recover the lost loop device file. > > > > # ./losetup -a > > /dev/loop0: [64512]:19133870 (/tmp/test.img) > > # rm -rf /dev/loop0 > > # ./losetup -d /dev/loop0 > > /dev/loop0 is lost, run "mknod /dev/loop0 b 7 0" to recover it. > > lt-losetup: /dev/loop0: detach failed: No such file or directory > > Maybe, but just maybe, we shouldn't provide instructions how to fix the > issue, but just print the major/minor numbers and let the user figure out > what's going on and how to fix the issue. The error message is just detail from my point of view :) Junxiao forgot to highlight that losetup (--all/--list) do not report at all the loop devices without /dev node. That's bug, because such devices are still used by kernel and should not be hidden for system admins. I'm just playing with it and I'll push Junxiao's patch with some modifications. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com