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 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. > 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. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com