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

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

 



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

 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

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com




[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