Subject: port-i386/525: Access to the "a" partition of a mitsumi cd rom drive is broken
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Duncan McEwan <duncan@Comp.VUW.AC.NZ>
List: netbsd-bugs
Date: 10/18/1994 19:20:09
>Number: 525
>Category: port-i386
>Synopsis: Access to the "a" partition of a mitsumi cd rom drive is broken
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Oct 18 19:20:06 1994
>Originator: Duncan McEwan
>Organization:
" Computer Science Department, Victoria University of Wellington, NZ"
>Release: netbsd-current supp'ed around 15th October.
>Environment:
System: NetBSD orsinis.pc.comp.vuw.ac.nz 1.0_BETA NetBSD 1.0_BETA (ORSINIS) #15: Tue Oct 18 17:34:08 NZDT 1994 duncan@orsinis.pc.comp.vuw.ac.nz:/usr/src/sys/arch/i386/compile/ORSINIS i386
>Description:
In a system with a mitsumi cd rom drive, running a kernel built with
device mcd0 at isa? port 0x300 irq 10
accessing /dev/mcd0a or /dev/rmcd0a doesn't work. Ie
orsinis# dd if=/dev/rmcd0a of=/dev/null
0+0 records in
0+0 records out
0 bytes transferred in 1 secs (0 bytes/sec)
and
orsinis# mount -t cd9660 -r /dev/mcd0a /mnt
cd9660: Invalid argument
My mcd devices look like:
br--r--r-- 1 root wheel 7, 0 Oct 15 00:21 /dev/mcd0a
br--r--r-- 1 root wheel 7, 3 Oct 15 00:21 /dev/mcd0d
cr--r--r-- 1 root wheel 39, 0 Oct 15 00:21 /dev/rmcd0a
cr--r--r-- 1 root wheel 39, 3 Oct 15 00:21 /dev/rmcd0d
The problem is that if you access a partition other than the raw ('d')
one, mcdstrategy() calls i386/disksubr.c:bounds_check_with_label() to
ensure that the requested transfer is within the bounds defined by the
disk label.
Bounds_check_with_label() sets maxsz of the (only) partition from
mcdcd.cd_devs[0]->dlabel.d_partitions[0].p_size. But this value is
always zero, so maxsz - bp->b_blkno is always < 0. Hence the immediate
end of file when using "dd" and the EINVAL when trying to mount the
disk.
The reason the p_size field is always zero is that it is initialised
from sc->disksize in mcd_getdisklabel(), which is called from mcdopen().
Unfortunately, sc->disksize is itself initialised by a call to
mcdsize() *after* the call to mcd_getdisklabel()...
>How-To-Repeat:
As above.
>Fix:
Two possible fixes:
1) Get rid of the {r,}mcd0a devices, and document the fact that you
should only use /dev/mcd0d and /dev/rmcd0d.
2) Apply the following patch which allows the {r,}mcd0a devices to work
as well (at least for me).
*** mcd.c.ORIG Sun Aug 7 22:33:10 1994
--- mcd.c Tue Oct 18 17:33:40 1994
***************
*** 238,251 ****
if (mcd_getstat(sc, 1) < 0)
return ENXIO;
- /* XXX Get a default disklabel. */
- mcd_getdisklabel(sc);
-
if (mcdsize(dev) < 0) {
printf("%s: failed to get disk size\n", sc->sc_dev.dv_xname);
return ENXIO;
} else
sc->flags |= MCDVALID;
MCD_TRACE("open: partition=%d disksize=%d blksize=%d\n", part,
sc->disksize, sc->blksize, 0);
--- 238,251 ----
if (mcd_getstat(sc, 1) < 0)
return ENXIO;
if (mcdsize(dev) < 0) {
printf("%s: failed to get disk size\n", sc->sc_dev.dv_xname);
return ENXIO;
} else
sc->flags |= MCDVALID;
+
+ /* XXX Get a default disklabel. */
+ mcd_getdisklabel(sc);
MCD_TRACE("open: partition=%d disksize=%d blksize=%d\n", part,
sc->disksize, sc->blksize, 0);
>Audit-Trail:
>Unformatted: