Hi there,
mkdosfs seems to be broken with kernel 2.6. I ran into the problem while I was trying to create a fat filesystem on a DVD-RAM medium. As you found out the ioctl for HDIO_GETGEO is broken. So I wrote a hotfix that
just sets heads to 255 and sectors/track to 63. At most harddisks seem to use that geometry that fix should work for larger disks. I only use the hardcoded values in case the ioctl fails. Patch is attached.
Cheers, Alex
--- dosfstools-2.10/mkdosfs/mkdosfs.c 2003-06-14 22:07:08.000000000 +0200
+++ dosfstools-2.10-patched/mkdosfs/mkdosfs.c 2005-03-11 15:31:47.000000000
+0100
@@ -609,7 +609,7 @@
long loop_size;
struct hd_geometry geometry;
struct floppy_struct param;
-
+
if ((0 == device_num) || ((device_num & 0xff00) == 0x0200))
/* file image or floppy disk */
{
@@ -765,10 +765,16 @@
{
/* Can we get the drive geometry? (Note I'm not too sure about */
/* whether to use HDIO_GETGEO or HDIO_REQ) */
- if (ioctl (dev, HDIO_GETGEO, &geometry))
- die ("unable to get drive geometry for '%s'");
- bs.secs_track = CT_LE_W(geometry.sectors); /* Set up the geometry
information */
- bs.heads = CT_LE_W(geometry.heads);
+ if (ioctl (dev, HDIO_GETGEO, &geometry)) {
+ /*die ("unable to get drive geometry for '%s'");*/
+ printf("Warning, couldn't read disk geometry, using 255 heads, 63
cylinders.\n");
+ printf("Good luck.\n");
+ bs.secs_track = CT_LE_W(63);
+ bs.heads= CT_LE_W(255);
+ } else {
+ bs.secs_track = CT_LE_W(geometry.sectors); /* Set up the geometry
information */
+ bs.heads = CT_LE_W(geometry.heads);
+ }
def_hd_params:
bs.media = (char) 0xf8; /* Set up the media descriptor for a hard drive
*/
bs.dir_entries[0] = (char) 0; /* Default to 512 entries */

