Re: fdisk -l finds CD-ROM

Russell Coker - mailing lists account (bofh@snoopy.virtual.net.au)
Wed, 16 Jul 97 19:46:33 +1100


>>I don't know whether this is a kernel issue; anyway:
>>When I start "fdisk -l" my CD-ROM drive spins up and then fdisk reports
>>the same geometry for /dev/hdd (CD) as for /dev/hda (disk), but no
>>partition table. Is the CD-ROM drive broken, the kernel, or fdisk?

>>From hdparm -i /dev/hdd I get:

>>Model=TOSHIBA CD-ROM XM-5602B, FwRev=1796, SerialNo=61517072
>>Config={ SpinMotCtl Removable DTR<=5Mbs DTR >10Mbs nonMagnetic }
>>RawCHS=0/0/0, TrkSize=0, SectSize=0, ECCbytes=0
>>BuffType=0(?), BuffSize=256kB, MaxMultSect=0
>>...

>>The kernel (2.0.29) recognizes the drive as
>><4>hdd: TOSHIBA CD-ROM XM-5602B, ATAPI CDROM drive

> This is a bug in the fdisk program, if the HDIO_GETGEO ioctl call fails
>then it takes the values from the previous successful call. Here is a
>patch for fdisk to solve this:

Now here's a better patch. I originally thought I'd have to patch the
kernel to do this (and decided to post a message before attempting that).
Then I discovered how to fix this properly:

--- fdisk.c.old Wed Jul 16 18:29:48 1997
+++ fdisk.c Wed Jul 16 19:45:15 1997
@@ -476,7 +476,21 @@
sector_offset = sectors;
warn_cylinders();
}
- else update_units();
+ else
+ {
+ if (!ioctl(fd, BLKGETSIZE, &sectors))
+ {
+ heads = 1;
+ cylinders = 1;
+ }
+ else
+ {
+ heads = 0;
+ cylinders = 0;
+ sectors = 0;
+ update_units();
+ }
+ }
warn_geometry();

for (i = 0; i < 4; i++)

Russell coker