Util-Linux Archive mirror
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: junxiao.bi@oracle.com
Cc: util-linux@vger.kernel.org, thomas@t-8ch.de, dsimic@manjaro.org
Subject: Re: [PATCH V2] loopdev: report lost loop device file error
Date: Mon, 27 Nov 2023 10:09:45 +0100	[thread overview]
Message-ID: <20231127090945.xjqvrtk7l2hlaf5w@ws.net.home> (raw)
In-Reply-To: <00af5617-923e-41d8-8b23-60178bb6db7a@oracle.com>

On Wed, Nov 01, 2023 at 12:54:16PM -0700, junxiao.bi@oracle.com 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@redhat.com>
 http://karelzak.blogspot.com


      reply	other threads:[~2023-11-27  9:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 20:36 [PATCH V2] loopdev: report lost loop device file error Junxiao Bi
2023-10-31 17:34 ` Dragan Simic
2023-11-01 10:05   ` Karel Zak
2023-11-01 11:55 ` Karel Zak
2023-11-01 19:54   ` junxiao.bi
2023-11-27  9:09     ` Karel Zak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231127090945.xjqvrtk7l2hlaf5w@ws.net.home \
    --to=kzak@redhat.com \
    --cc=dsimic@manjaro.org \
    --cc=junxiao.bi@oracle.com \
    --cc=thomas@t-8ch.de \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).