summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_msdosfs/boot.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2010-02-14 12:30:30 +0000
committerkib <kib@FreeBSD.org>2010-02-14 12:30:30 +0000
commit53d879fa5d2a904194842a5da8dafd38d49957a1 (patch)
treef010d5d622bf13ee9314552bbfaa749698331ae3 /sbin/fsck_msdosfs/boot.c
parentce3384ad3e81febc6f64d45a171384ba24401471 (diff)
downloadFreeBSD-src-53d879fa5d2a904194842a5da8dafd38d49957a1.zip
FreeBSD-src-53d879fa5d2a904194842a5da8dafd38d49957a1.tar.gz
Bug fixes from NetBSD
- fix sign-compare issues. - ANSIfy a couple of functions. - Remove more duplicate #includes. - Memory leak found by Coverity on NetBSD. Submitted by: Pedro F. Giffuni <giffunip tutopia com> Reviewed by: bde MFC after: 2 weeks
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