[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fsck_msdos



I kept getting the error message that the backup boot partition didn't match the primary boot partiation of my windows MSDOS drives from FSCK during boot.  Using your boot.c code in /usr/src/sbin/fsck_msdos I decoded the backup boot partition in the same manner that you decoded the primary boot partition to check each value and found that all values matched up for both blocks through the first 91 bytes.  I noticed that your code did not use anything past the 52nd byte and microsofts description of the header does not show any additional data past that point.  I therefore, assume that it's just empty space and can contain whatever happend to be on disk at the time.  Thus,  I implemented the following changes to the boot.c code on my system begining on line 154:
 
 
/*
 * According to Microsoft, the backup address has to be greater than 0 and less than ResSectors
 * in order for it to be valid.  So, I added a check for that.
 */

    if (boot->Backup > 0 && boot->Backup < boot->ResSectors) { 

            if (lseek(dosfs, boot->Backup * boot->BytesPerSec, SEEK_SET)

                    != boot->Backup * boot->BytesPerSec

                    || read(dosfs, backup, sizeof backup) != sizeof backup) {

                            perror("could not read backup bootblock");

                    return FSFATAL;

              } 

               if (backup[510] != 0x55 || backup[511] != 0xaa) {

                        pfatal("Invalid signature in backup block: %02x%02x", backup[510], backup[511]);

                        return FSFATAL;

               }

/*

* only check first 52 bytes of the block

*/

                if (memcmp(block, backup, 52)) { /* used to be DOSBOOTBLOCKSIZE */

                            /* Correct? XXX */

                            pfatal("backup doesn't compare to primary bootblock");

                            return FSFATAL;

                }       

                /* CHeck backup FSINFO? */

    }

With this change, I am able to have both my Windows Me drives (C: & D:) mounted at boot time as the fsck does not abort with the error anymore.

 

Regards,

 

Steven E. Kalbach

 

Voice:  641-693-4065

Fax:     641-693-3033