Re: The Linux 64 GiB Limit - was: Re: oops! Should be fdisk broken?

Michael Elizabeth Chastain (mec@shout.net)
Mon, 25 Jan 1999 18:23:02 -0600


Hi Andries,

--- hdreg.h~ Fri Jan 22 16:49:34 1999
+++ hdreg.h Mon Jan 25 23:13:06 1999
@@ -114,7 +114,7 @@
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
- unsigned short cylinders;
+ unsigned long cylinders;
unsigned long start;
};

Watch out, here comes a headache.

'struct hd_geometry' is part of the kernel interface to applications,
thanks to HDIO_GETGEO.

I think that the current 'struct hd_geometry' is frozen in stone.
You will have to make 'struct hd_new_geometry' and HDIO_NEW_GETGEO.
I recommend making all the fields ints and longs while you are in
there.

Then edit all the files that implement HDIO_GETGEO. I count 20 such
files in 2.1.105 (hey I know that's a strange version but that's what's
on my tiny hard disk right this moment).

As of 2.1.117, HDIO_GETGEO is the only ioctl that uses this struct.
But for the sake of safety you should do a global search for hd_geometry
as well.

By the way there is some really disgusting coding in many of the
HDIO_GETGEO implementations that looks like this:

put_user( ..., (unsigned char *) &ptr->heads );
put_user( ..., (unsigned char *) &ptr->sectors );
put_user( ..., (unsigned short *) &ptr->cylinders );
put_user( ..., (unsigned long *) &ptr->start );

Please don't copy that style into HDIO_NEW_GETGEO! Just have an
an instance of hd_new_geometry on the stack already. It's about 12
or 16 bytes long. Then one copy_to_user call does the job.

Hope this helps,

Michael Elizabeth Chastain
<mailto:mec@shout.net>
"love without fear"

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/