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

fsck_msdos misdetects corruption



>Submitter-Id: kousu
>Originator: Nick Guenther
>Organization:
>Synopsis: fsck_msdos detects a bad partition when it's actually okay
>Severity: non-critical
>Priority: medium
>Catergory: system
>Class: sw-bug
>Release: 3.8-Release
>Environment:
	System	: OpenBSD 3.8
	Architecture	: OpenBSD.i386
	Machine:	: i386
>Description:
	Runng fsck_msdos on FAT32 partitions that have been corrupted in a
certain way causes "backup doesn't compare to primary bootblock" even
when the corresponding microsoft tools say the disk is clean. This is
because it compares too much of the primary and backup bootblocks on a
FAT32 partition. It should only compare the first 52 bytes but it
compares the entirety of the DOS boot block.
>How-To-Repeat:
	Format a new FAT32 partition (ideally using microsoft tools). If you
run fsck_msdos on this it is fine because the primary and backup
bootblocks were both initialized the same way (presumable to nulls).
However, if you corrupt one of them (pulling the power while it's
running will do this) and then try fsck_msdos you see "backup doesn't
compare to primary bootblock"; this occurs even if you run scandisk
(from windows) on the partition before trying fsck_msdos because
scandisk will only fix the first 52 bytes and ignores the rest of the
boot block.
>Fix:
	The fix for this was actually provided years ago, but appearantly was
forgotten, so I'm reminding you. See
http://www.monkey.org/openbsd/archive/bugs/0105/msg00085.html for the
fix. Basically, just go into /usr/src/sbin/fsck_msdos/boot.c and
change
if(memcmp(block, backup, DOSBOOTBLOCKSIZE ))
to
if(memcmp(block, backup, 52))
There's something else in that message too that I don't understand but
is probably worth looking at.