From f74695618bd347cc42632794c278b208e464d6e9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 26 Sep 2008 15:18:35 +0200 Subject: [PATCH] Applying Suses dosfstools-2.11-mkdosfs-geo0.diff from Ludwig Nussel to fix handling of zero heads and sectors: * the HDIO_GETGEO ioctl works on device mapper devices but returns zero heads and sectors. Therefore let's a) assume dummy values in that case in mkdosfs and b) don't consider such fat file systems as invalid in dosfsck. The Linux kernel accepts them anyways. Signed-off-by: Daniel Baumann --- dosfsck/boot.c | 2 ++ mkdosfs/mkdosfs.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dosfsck/boot.c b/dosfsck/boot.c index ae1a98f..bc9da05 100644 --- a/dosfsck/boot.c +++ b/dosfsck/boot.c @@ -375,9 +375,11 @@ void read_boot(DOS_FS *fs) if (logical_sector_size & (SECTOR_SIZE-1)) die("Logical sector size (%d bytes) is not a multiple of the physical " "sector size.",logical_sector_size); +#if 0 /* linux kernel doesn't check that either */ /* ++roman: On Atari, these two fields are often left uninitialized */ if (!atari_format && (!b.secs_track || !b.heads)) die("Invalid disk format in boot sector."); +#endif if (verbose) dump_boot(fs,&b,logical_sector_size); } diff --git a/mkdosfs/mkdosfs.c b/mkdosfs/mkdosfs.c index 33aa028..efc8233 100644 --- a/mkdosfs/mkdosfs.c +++ b/mkdosfs/mkdosfs.c @@ -746,8 +746,8 @@ establish_params (int device_num,int size) { /* 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)) { - printf ("unable to get drive geometry, using default 255/63"); + if (ioctl (dev, HDIO_GETGEO, &geometry) || geometry.sectors == 0 || geometry.heads == 0) { + printf ("unable to get drive geometry, using default 255/63\n"); bs.secs_track = CT_LE_W(63); bs.heads = CT_LE_W(255); }