* [PATCH] scsi: sr: exclude CDC_MRW_W and CDC_RAM from writeable check
@ 2026-03-30 13:34 Daan De Meyer
0 siblings, 0 replies; only message in thread
From: Daan De Meyer @ 2026-03-30 13:34 UTC (permalink / raw)
To: linux-scsi; +Cc: James.Bottomley, martin.petersen, Daan De Meyer, Daan De Meyer
The writeable check in get_capabilities() includes CDC_MRW_W and
CDC_RAM in its bitmask, but these capabilities are not determined from
the MODE SENSE capabilities page. They require the SCSI GET
CONFIGURATION command, which is only issued later by cdrom_open_write()
at device open time.
Since cdi.mask is initialized to zero (all capabilities assumed
present), CDC_MRW_W and CDC_RAM are left unmasked by default. This
makes the writeable check always true when MODE SENSE succeeds,
regardless of the drive's actual write capabilities as reported in the
capabilities page.
Fix this by only checking CDC_DVD_RAM and CDC_CD_RW in the writeable
condition, as these are the write capabilities actually determined from
the MODE SENSE capabilities page. CDC_MRW_W and CDC_RAM will continue
to be evaluated by cdrom_open_write() at open time via GET
CONFIGURATION.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
---
drivers/scsi/sr.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 8ed002f82e36..0a6413b77dd3 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -901,10 +901,14 @@ static int get_capabilities(struct scsi_cd *cd)
cd->cdi.mask |= CDC_CLOSE_TRAY; */
/*
- * if DVD-RAM, MRW-W or CD-RW, we are randomly writable
+ * Check if the drive has write capabilities. Only consider
+ * capabilities that are determined from the MODE SENSE capabilities
+ * page here. CDC_MRW_W (MRW writing) and CDC_RAM (random writable)
+ * require the SCSI GET CONFIGURATION command to determine, which
+ * is issued later by cdrom_open_write() at device open time.
*/
- if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) !=
- (CDC_DVD_RAM | CDC_MRW_W | CDC_RAM | CDC_CD_RW)) {
+ if ((cd->cdi.mask & (CDC_DVD_RAM | CDC_CD_RW)) !=
+ (CDC_DVD_RAM | CDC_CD_RW)) {
cd->writeable = 1;
}
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-30 13:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 13:34 [PATCH] scsi: sr: exclude CDC_MRW_W and CDC_RAM from writeable check Daan De Meyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox