On 5/23/18 3:19 AM, Maurizio Lombardi wrote: > > > Dne 22.5.2018 v 16:47 Jens Axboe napsal(a): >> It's been many years, but back in the day the program writing the cd >> would eject the disc once done. This of course forces a reload of >> the toc and clearing of the flag. What program is this? Seems like >> it should probably eject when it's done. > > They are using wodim to burn the CDs on their servers. > The problem is that they do not want the CD to be ejected because their drives > lack a motorized tray, thus requiring manual intervention which they would like to avoid. I took a quick look at it, man that sr driver needs a bit of love :-) Anyway, I wonder if something like the below would work. Check for a close track command in the sr completion handler, and flag the media as changed if we see one. Totally untested... diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3f3cb72e0c0c..48f0d7a096db 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -328,6 +328,9 @@ static int sr_done(struct scsi_cmnd *SCpnt) scmd_printk(KERN_INFO, SCpnt, "done: %x\n", result); #endif + if (SCpnt->cmnd[0] == GPCMD_CLOSE_TRACK) + cd->device->changed = 1; + /* * Handle MEDIUM ERRORs or VOLUME OVERFLOWs that indicate partial * success. Since this is a relatively rare error condition, no -- Jens Axboe