Applying Suses dosfstools-2.11-mkdosfs-geo0.diff from Ludwig Nussel

<lnussel@suse.de> 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 <mail@daniel-baumann.ch>
This commit is contained in:
Daniel Baumann 2008-09-26 15:18:35 +02:00
parent cf243e4a84
commit f74695618b
2 changed files with 4 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);
}