Re: [PATCH V2] loopdev: report lost loop device file error

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

 



On 11/1/23 4:55 AM, Karel Zak wrote:

On Wed, Oct 25, 2023 at 01:36:03PM -0700, 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.
  Thanks Junxiao,

  I has move aggressive with the changes and there is result:
  https://github.com/util-linux/util-linux/pull/2566
Thanks a lot. The changes looks good to me.

  For me the most important is to report used devices although there is
  not /dev loop node.

+static void loopcxt_scan_lost_device_file(struct loopdev_cxt *lc)
+{
+	static int scanned = 0;
+	dev_t devno;
+
+	/*only scan sysfs once for losetup cmd*/
+	if (!scanned)
+		scanned = 1;
+	else
+		return;
+	devno = sysfs_devname_to_devno(lc->device);
+	if (devno <= 0)
+		return;
+
+	fprintf(stderr, "%s is lost, run \"mknod %s b %d %d\" to recover it.\n",
+			lc->device, lc->device, major(devno), minor(devno));
+}
  The lib/loopdev.c code is also used in libmount, so it should not
  directly print anything on stderr. It's application business to print
  the warning. I have moved it to losetup.c

Should we patch mount to report that error? with current patch, it report this:

# ./mount -o loop /tmp/test.img /mnt/
lt-mount: /mnt/: mount failed: No such file or directory.

Thanks,

Junxiao.


     Karel




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux