On Tue, Jan 07, 2020 at 05:19:18PM +0100, Michal Suchánek wrote: > On Tue, Jan 07, 2020 at 05:04:43PM +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. > > > > I found unwanted side effect, open() with O_NONBLOCK also successes > > when there is no medium. Unfortunately, we ignore I/O errors for > > CDROMs to support some crazy hybrid media -- so overall result is many > > I/O warnings in system logs. > > > > I have added CDROM_DRIVE_STATUS to the logic to stop probing when > > there is no medium. Let's hope it will be enough: > > > > https://github.com/karelzak/util-linux/commit/dc30fd4383e57a0440cdb0e16ba5c4336a43b290 > > It it probably safer to do > switch (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT)) { > to support some crazy CD changers. Good point, I have seen it in kernel docs, but forgot to use it. Fixed. Thanks for review. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com