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

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

 



On Wed, Nov 01, 2023 at 12:54:16PM -0700, junxiao.bi@xxxxxxxxxx wrote:
> 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? 

Yes, but first we need improve how libmount works with errors. Now
there is possible to work with errno only. The code that generates
error messages has no access to the 'struct loopdev_cxt`.

I have added a TODO issue for this:
https://github.com/util-linux/util-linux/issues/2605

    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