From: "Michal Suchánek" <msuchanek@suse.de>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] blkid: open device in nonblock mode.
Date: Tue, 5 Nov 2019 18:13:57 +0100 [thread overview]
Message-ID: <20191105171357.GV1384@kitsune.suse.cz> (raw)
In-Reply-To: <20191105114122.o3cjzfnoy3hp2rbm@10.255.255.10>
On Tue, Nov 05, 2019 at 12:41:22PM +0100, Karel Zak wrote:
> On Mon, Nov 04, 2019 at 09:23:15PM +0100, Michal Suchanek wrote:
> > When autoclose is set (kernel default but many distributions reverse the
> > setting) opening a CD-rom device causes the tray to close.
> >
> > The function of blkid is to report the current state of the device and
> > not to change it. Hence it should use O_NONBLOCK when opening the
> > device to avoid closing a CD-rom tray.
>
> I can imagine this as optional solution (command line option), but I
That defeats the purpose of this change. You cannot use the option with
old blkid, so using the option is broken and not using it is also broken.
> have doubts to use O_NONBLOCK by default for all block devices. I have
> no example, but it sounds like a way how to introduce regressions in
> libblkid behavior. (Any kernel guy around?) Is it really only cdrom
> driver(s) where O_NONBLOCK has any impact? What about USB, some random
> SCSI, ... I don't know.
>
> The another problem is that the library does not have to open the device,
> you can use already open file descriptor (blkid_probe_set_device()).
> So, in many cases the patch will have no effect.
If some random program using libblkid closes the tray I don't care that
much. However, many system scripts use blkid, probably to find a device
with particular ID:
/usr/bin/dracut: dev=$(blkid -l -t UUID=${dev#UUID=} -o
device)
/usr/bin/dracut: dev=$(blkid -l -t LABEL=${dev#LABEL=} -o
device)
/usr/bin/dracut: dev=$(blkid -l -t PARTUUID=${dev#PARTUUID=}
-o device)
/usr/bin/dracut: dev=$(blkid -l -t
PARTLABEL=${dev#PARTLABEL=} -o device)
/usr/bin/linux-boot-prober: partition=$(blkid | grep "$UUID" | cut
-d ':' -f 1 | tr '\n' ' ' | cut -d ' ' -f 1)
/usr/bin/os-prober: blkid | grep btrfs | cut -d ':' -f 1
/usr/bin/os-prober: type=$(blkid -o value -s TYPE $mapped || true)
/usr/bin/os-prober: uuid=$(blkid -o value -s UUID $mapped)
>
> > blkid is used liberally in scripts so it can potentially interfere with
> > the user operating the CD-rom hardware.
>
> It's better to use lsblk in script, it reads info from udev -- call
> blindly blkid(8) is usually overkill.
First off you need to explain it to all authors of all random scripts
out there.
Secondly udev is not guaranteed to exist/run on every system.
Thanks
Michal
next prev parent reply other threads:[~2019-11-05 17:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 20:23 [PATCH] blkid: open device in nonblock mode Michal Suchanek
2019-11-05 11:41 ` Karel Zak
2019-11-05 17:13 ` Michal Suchánek [this message]
2019-11-06 8:02 ` Michal Suchánek
2019-11-06 8:48 ` Karel Zak
2019-11-06 9:45 ` Michal Suchánek
2019-11-12 8:27 ` Anatoly Pugachev
2019-11-12 8:58 ` Karel Zak
2019-11-06 9:00 ` Karel Zak
2020-01-07 16:04 ` Karel Zak
2020-01-07 16:19 ` Michal Suchánek
2020-01-08 8:25 ` Karel Zak
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=20191105171357.GV1384@kitsune.suse.cz \
--to=msuchanek@suse.de \
--cc=kzak@redhat.com \
--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 NNTP newsgroup(s).