On Fri, Jul 21, 2017 at 08:44:03PM +0200, Stanislav Brabec wrote: > @@ -1399,6 +1405,7 @@ int mnt_context_get_mount_excode( > /* > * mount(2) errors > */ > +mount_retry: > syserr = mnt_context_get_syscall_errno(cxt); > > > @@ -1563,6 +1570,19 @@ int mnt_context_get_mount_excode( > break; > > case ENOMEDIUM: > + cdrom = open(mnt_context_get_source(cxt), O_RDONLY | O_NONBLOCK); > + if (cdrom != -1) { > + if (retries < CRDOM_TRAYOPEN_RETRIES && > + (ioctl(cdrom, CDROM_GET_CAPABILITY, NULL) & CDC_CLOSE_TRAY) && > + ioctl(cdrom, CDROM_DRIVE_STATUS, NULL) == CDS_TRAY_OPEN) { > + ioctl(cdrom, CDROMCLOSETRAY); > + close(cdrom); > + sleep(3); > + ++retries; > + goto mount_retry; > + } else > + close(cdrom); > + } This cannot work. It seem you have tested the tray-close only, but I guess your goal is also *mount* the device. The "goto mount_retry" does not call any mount(2) stuff :-) The function mnt_context_get_mount_excode() is wrong place. This optional function is there to generate error message and exit code. Nothing else. The right place for your code is mnt_context_mount() where we already have the same logic ("try mount again") for read-only devices. You need something like: if (mnt_context_syscall_called(cxt) && mnt_context_get_syscall_errno(cxt) == ENOMEDIUM) { ... your open() and ioctls ... goto again; } Use findmnt(8) to be sure that CDROM is really mounted. Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html