View previous topic :: View next topic |
Author |
Message |
salahx Guru
Joined: 12 Mar 2005 Posts: 559
|
Posted: Fri May 12, 2006 6:27 am Post subject: Linux & Mt. Rainier formatting / access |
|
|
Linux has had Mt. Rainier support since 2.6.10, however, there seems to be no way to actually formatting the discs. There is source code for it (which isn't in Portage, BTW) but it doesn't work for me (and hasn't been updated in 4 years), even though my drive (claims) to support it (via /proc/sys/dev/cdrom/info).
There is actually code in the Linux kernel (in drivers/cdrom/cdrom.c) do that, however no code paths cross it, not even an IOCTL. As cdrom.c has not yet ben ported to kbojects/sysfs, I created a patch to add an ioctl:
Code: |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index a59876a..0acf02b 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2681,6 +2681,56 @@ static int cdrom_ioctl_audioctl(struct c
return cdi->ops->audio_ioctl(cdi, cmd, NULL);
}
+static int cdrom_ioctl_mrw_format(struct cdrom_device_info *cdi,
+ unsigned int mrw_format)
+{
+ int ret;
+ disc_information di;
+
+ cdinfo(CD_DO_IOCTL, "doing Mount Rainier format (start/suspend)\n");
+
+ if (!CDROM_CAN(CDC_MRW_W))
+ return -ENOSYS;
+
+ ret = cdrom_get_disc_info(cdi, &di);
+ if (ret < 0 || ret < (int)offsetof(typeof(di),disc_type))
+ return 1;
+
+ switch(mrw_format) {
+ case 1:
+ switch(di.mrw_status) {
+ case CDM_MRW_NOTMRW:
+ ret = cdrom_mrw_bgformat(cdi,0);
+ break;
+ case CDM_MRW_BGFORMAT_INACTIVE:
+ ret = cdrom_mrw_bgformat(cdi,1);
+ break;
+ case CDM_MRW_BGFORMAT_ACTIVE:
+ ret = -EAGAIN;
+ break;
+ }
+ break;
+ case 0:
+ switch(di.mrw_status) {
+ case CDM_MRW_BGFORMAT_ACTIVE:
+ ret = cdrom_mrw_bgformat_susp(cdi, 1);
+ break;
+ case CDM_MRW_BGFORMAT_INACTIVE:
+ ret = -EAGAIN;
+ break;
+ case CDM_MRW_BGFORMAT_COMPLETE:
+ ret = 1;
+ break;
+ case CDM_MRW_NOTMRW:
+ ret = -EMEDIUMTYPE;
+ break;
+ }
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ return ret;
+}
/*
* Just about every imaginable ioctl is supported in the Uniform layer
* these days.
@@ -3077,6 +3127,8 @@ static int mmc_ioctl(struct cdrom_device
IOCTL_OUT(arg, long, last);
return 0;
}
+ case CDROM_MRW_FORMAT:
+ return cdrom_ioctl_mrw_format(cdi,arg);
} /* switch */
return -ENOTTY;
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index 3c9b0bc..da79976 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -127,6 +127,7 @@ #define CDROM_CHANGER_NSLOTS 0x5328
#define CDROM_LOCKDOOR 0x5329 /* lock or unlock door */
#define CDROM_DEBUG 0x5330 /* Turn debug messages on/off */
#define CDROM_GET_CAPABILITY 0x5331 /* get capabilities */
+#define CDROM_MRW_FORMAT 0x5332 /* Mt. Rainier format & suspend */
/* Note that scsi/scsi_ioctl.h also uses 0x5382 - 0x5386.
* Future CDROM ioctls should be kept below 0x537F
|
And a very simple tool to use it:
Code: |
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include "linux/cdrom.h"
int main(void)
{
int cdfd;
if((cdfd = open("/dev/hdc",O_RDWR|O_NONBLOCK)) == -1)
{
perror("open");
return errno;
}
if(ioctl(cdfd,CDROM_MRW_FORMAT,1UL) == -1)
{
perror("ioctl");
close(cdfd);
return errno;
}
return 0;
}
|
If you want to compile this, you'll need to make sure the (modified) kernel headers are on the include path:
Code: |
gcc -o mrw -I/usr/src/linux/include mrw.c
|
Everything compiles fine but it STILL doesn't format
Code: |
cdrom: starting format
hdc: packet command error: status=0x51 { DriveReady SeekComplete Error }
hdc: packet command error: error=0x54 { AbortedCommand LastFailedSense=0x05 }
ide: failed opcode was: unknown
cdrom: bgformat failed
|
Code: |
# ./mrw
ioctl: Input/output error
|
I'm not sure what going on - if it my code (yes, I know it ugly and would be laughed at by the kernel devs, this is just a "proof of concept"), my drive, or some other code. Anyone else have any luck with this patch? |
|
Back to top |
|
|
salahx Guru
Joined: 12 Mar 2005 Posts: 559
|
Posted: Sat May 13, 2006 4:26 am Post subject: |
|
|
Well, I just figured out why this doesn't work: My CD drive does not support Mt. Rainier . /proc/sys/dev/cdrom/info lies.
I'm surprised: For a standard that has existed since for 4 to 5 years with the support of 40+ vendors has gotten so little adaption. In fact it seems _NO_ DVD writer support Mt. Rainier - at least, not any with any publically avaiable firmware; and only a handful of CD recorders do. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|