Re: writable mmc profiles actually are writable

Jens Axboe
2003-10-06T18:22:31Z

On Mon, Oct 06 2003, Pat LaVarre wrote:
> > Newsgroups: mlist.linux.scsi
> > Date: 2003-09-10 16:00:27 PST
> > Subject: Re: [PATCH] mount -w of dvd+rw etc. in vanilla 2.6
> > From: Patrick Mansfield (patmans@us.ibm.com)
> >
> > Should sd.c and sr.c be calling set_device_ro?
> > (after adding a read only block device, or
> > changing back to read/write)?
>
> That good question stands open, I think.
>
> The following inline plain text, now revved for -test6 & posted here,
> allows modprobe to overcome such uncooperative attitudes as:
>
> $ sudo dd if=/dev/scd2 bs=2k count=1 | wc
> 1+0 records in
> 1+0 records out
> 0 0 2048
> $
> $ sudo dd of=/dev/scd2 bs=2k count=1 if=/dev/zero
> dd: opening `/dev/scd2': Read-only file system
> $
>
> Allowing dd, mkudffs, etc. are the good consequences. The evil
> consequences I do not yet know. I do notice we have achieved
> writability without extending the enumeration that `cat
> /proc/sys/dev/cdrom/info` dumps:
>
> Can write CD-R: 0
> Can write CD-RW: 0
> Can read DVD: 0
> Can write DVD-R: 0
> Can write DVD-RAM: 0

And the device isn't writable, so...?

> diff -ur linux-2.6.0-test6/drivers/cdrom/cdrom.c linux/drivers/cdrom/cdrom.c
> --- linux-2.6.0-test6/drivers/cdrom/cdrom.c 2003-09-27 18:50:10.000000000 -0600
> +++ linux/drivers/cdrom/cdrom.c 2003-10-06 11:53:41.826299728 -0600
> @@ -426,8 +426,8 @@
> if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS))
> ret = cdi->ops->open(cdi, 1);
> else {
> - if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
> - return -EROFS;
> +// if ((fp->f_mode & FMODE_WRITE) && !CDROM_CAN(CDC_DVD_RAM))
> +// return -EROFS;
>
> ret = open_for_data(cdi);
> }
> diff -ur linux-2.6.0-test6/drivers/scsi/sr.c linux/drivers/scsi/sr.c
> --- linux-2.6.0-test6/drivers/scsi/sr.c 2003-09-27 18:50:13.000000000 -0600
> +++ linux/drivers/scsi/sr.c 2003-10-06 11:51:59.655832000 -0600
> @@ -327,8 +327,8 @@
> }
>
> if (rq_data_dir(SCpnt->request) == WRITE) {
> - if (!cd->device->writeable)
> - return 0;
> +// if (!cd->device->writeable)
> +// return 0;
> SCpnt->cmnd[0] = WRITE_10;
> SCpnt->sc_data_direction = SCSI_DATA_WRITE;
> } else if (rq_data_dir(SCpnt->request) == READ) {

This is obviously wrong. What are you trying to do? The uniform layer
uses CDC_DVD_RAM as meaning randomly writable media, the only thing the
kernel supports out of the box. So that is what the test is for.

Honestly, I have no idea what your are trying to pull. Calling read-only
media failing to be opened read-write as "uncooperative" is confusing,
borderline amusing :). Explain yourself in clear text, thanks.

--
Jens Axboe