summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_msdosfs/boot.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_msdosfs/boot.c')
-rw-r--r--sbin/fsck_msdosfs/boot.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/sbin/fsck_msdosfs/boot.c b/sbin/fsck_msdosfs/boot.c
index 3a9de4c..d842943 100644
--- a/sbin/fsck_msdosfs/boot.c
+++ b/sbin/fsck_msdosfs/boot.c
@@ -33,7 +33,6 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
@@ -41,16 +40,15 @@ static const char rcsid[] =
#include "fsutil.h"
int
-readboot(dosfs, boot)
- int dosfs;
- struct bootblock *boot;
+readboot(int dosfs, struct bootblock *boot)
{
u_char block[DOSBOOTBLOCKSIZE];
u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
u_char backup[DOSBOOTBLOCKSIZE];
int ret = FSOK;
+ int i;
- if (read(dosfs, block, sizeof block) < sizeof block) {
+ if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
perror("could not read boot block");
return FSFATAL;
}
@@ -154,12 +152,22 @@ readboot(dosfs, boot)
}
backup[65] = block[65]; /* XXX */
if (memcmp(block + 11, backup + 11, 79)) {
- /* Correct? XXX */
- pfatal("backup doesn't compare to primary bootblock");
- if (alwaysno)
- pfatal("\n");
- else
- return FSFATAL;
+ /*
+ * XXX We require a reference that explains
+ * that these bytes need to match, or should
+ * drop the check. gdt@NetBSD has observed
+ * filesystems that work fine under Windows XP
+ * and NetBSD that do not match, so the
+ * requirement is suspect. For now, just
+ * print out useful information and continue.
+ */
+ pfatal("backup (block %d) mismatch with primary bootblock:\n",
+ boot->Backup);
+ for (i = 11; i < 11 + 90; i++) {
+ if (block[i] != backup[i])
+ pfatal("\ti=%d\tprimary 0x%02x\tbackup 0x%02x\n",
+ i, block[i], backup[i]);
+ }
}
/* Check backup FSInfo? XXX */
}
@@ -223,9 +231,7 @@ readboot(dosfs, boot)
}
int
-writefsinfo(dosfs, boot)
- int dosfs;
- struct bootblock *boot;
+writefsinfo(int dosfs, struct bootblock *boot)
{
u_char fsinfo[2 * DOSBOOTBLOCKSIZE];
OpenPOWER on IntegriCloud