DVD-R capability flag set incorrectly, /proc formatting fix
Subsystems (2)
PATCH 1/1 DVD-R capability flag set incorrectly, /proc formatting fix
This patch for scsi/sr.c and cdrom/cdrom.c persuades /proc/sys/dev/cdrom/info to report that connecting a drive via USB rather than ATAPI in fact does not make it able to write DVD-R.
In linux-2.6.2 without this patch, when sr0 and hdd are the same type of device connected via USB and ATAPI respectively, I see:
$ cat /proc/sys/dev/cdrom/info: drive name: sr1 sr0 hdd ... Can write CD-R: 1 0 0 Can write CD-RW: 1 0 0 Can read DVD: 0 0 0 Can write DVD-R: 1 1 0 Can write DVD-RAM: 0 0 0 Can read MRW: 0 0 0 Can write MRW: 0 0 0
With this patch applied, instead I see:
$ cat /proc/sys/dev/cdrom/info: drive name: sr1 sr0 hdd ... Can write CD-R: 1 0 0 Can write CD-RW: 1 0 0 Can read DVD: 0 0 0 Can write DVD-R: 0 0 0 Can write DVD-RAM: 0 0 0 Can read MRW: 0 0 0 Can write MRW: 0 0 0
The sr1 device in particular is an ordinary CD-RW that in fact cannot write DVD-R.
While messing with this code, I also thought to tweak the /proc formatting to align the tabbed columns.
---John McKell, Iomega Corp
drivers/scsi/sr.c +1 -2
@@ -795,10 +795,9 @@ static void get_capabilities(struct scsiif ((buffer[n +2 ] &0x8 ) ==0 )/* not a DVD drive */ cd->cdi.mask |=CDC_DVD ; -if ((buffer[n +3 ] &0x20 ) ==0 ) { +if ((buffer[n +3 ] &0x20 ) ==0 )/* can't write DVD-RAM media */ cd->cdi.mask |=CDC_DVD_RAM ; - }else if ((buffer[n +3 ] &0x10 ) ==0 )/* can't write DVD-R media */ cd->cdi.mask |=CDC_DVD_R ;
drivers/cdrom/cdrom.c +4 -4
@@ -2740,13 +2740,13 @@ int cdrom_sysctl_info(ctl_table *ctl, infor (cdi=topCdromPtr;cdi!=NULL ;cdi=cdi->next) pos +=sprintf (info+pos,"\t%d" ,CDROM_CAN (CDC_DVD_RAM ) !=0 ); - pos +=sprintf (info+pos,"\nCan read MRW:" ); + pos +=sprintf (info+pos,"\nCan read MRW:\t" );for (cdi=topCdromPtr;cdi!=NULL ;cdi=cdi->next) - pos +=sprintf (info+pos,"\t\t%d" ,CDROM_CAN (CDC_MRW ) !=0 ); + pos +=sprintf (info+pos,"\t%d" ,CDROM_CAN (CDC_MRW ) !=0 ); - pos +=sprintf (info+pos,"\nCan write MRW:" ); + pos +=sprintf (info+pos,"\nCan write MRW:\t" );for (cdi=topCdromPtr;cdi!=NULL ;cdi=cdi->next) - pos +=sprintf (info+pos,"\t\t%d" ,CDROM_CAN (CDC_MRW_W ) !=0 ); + pos +=sprintf (info+pos,"\t%d" ,CDROM_CAN (CDC_MRW_W ) !=0 );strcpy (info+pos,"\n\n" );
Quoted 44 lines · John McKell
This patch for
scsi/sr.candcdrom/cdrom.cpersuades/proc/sys/dev/cdrom/infoto report that connecting a drive via USB rather than ATAPI in fact does not make it able to write DVD-R.In linux-2.6.2 without this patch, when sr0 and hdd are the same type of device connected via USB and ATAPI respectively, I see:
$ cat /proc/sys/dev/cdrom/info: drive name: sr1 sr0 hdd ... Can write CD-R: 1 0 0 Can write CD-RW: 1 0 0 Can read DVD: 0 0 0 Can write DVD-R: 1 1 0 Can write DVD-RAM: 0 0 0 Can read MRW: 0 0 0 Can write MRW: 0 0 0With this patch applied, instead I see:
$ cat /proc/sys/dev/cdrom/info: drive name: sr1 sr0 hdd ... Can write CD-R: 1 0 0 Can write CD-RW: 1 0 0 Can read DVD: 0 0 0 Can write DVD-R: 0 0 0 Can write DVD-RAM: 0 0 0 Can read MRW: 0 0 0 Can write MRW: 0 0 0The sr1 device in particular is an ordinary CD-RW that in fact cannot write DVD-R.
While messing with this code, I also thought to tweak the /proc formatting to align the tabbed columns.
---John McKell, Iomega Corp
diff -Nurp
linux-2.6.2/drivers/scsi/sr.clinux/drivers/scsi/sr.cdrivers/scsi/sr.c +0
-0@@ -795,10 +795,9 @@ static void get_capabilities(struct scsiif ((buffer[n +2 ] &0x8 ) ==0 )
drivers/scsi/sr.c static void get_capabilities(struct scsi · line 803
Quoted 10 lines
drivers/scsi/sr.c +1
-2/* not a DVD drive */ cd->cdi.mask |=CDC_DVD ; -if ((buffer[n +3 ] &0x20 ) ==0 ) { +if ((buffer[n +3 ] &0x20 ) ==0 )/* can't write DVD-RAM media */ cd->cdi.mask |=CDC_DVD_RAM ; - }else if ((buffer[n +3 ] &0x10 ) ==0 )/* can't write DVD-R media */ cd->cdi.mask |=CDC_DVD_R ;
Good spotting, that's surely a bug!
Signature · 1 line
Jens Axboe