summaryrefslogtreecommitdiff
path: root/sbin/fsck_msdos
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_msdos')
-rw-r--r--sbin/fsck_msdos/check.c18
-rw-r--r--sbin/fsck_msdos/dir.c10
-rw-r--r--sbin/fsck_msdos/dosfs.h5
-rw-r--r--sbin/fsck_msdos/fat.c20
4 files changed, 34 insertions, 19 deletions
diff --git a/sbin/fsck_msdos/check.c b/sbin/fsck_msdos/check.c
index 8e789062c9e..629e70d8e8b 100644
--- a/sbin/fsck_msdos/check.c
+++ b/sbin/fsck_msdos/check.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: check.c,v 1.3 1996/06/23 14:30:41 deraadt Exp $ */
-/* $NetBSD: check.c,v 1.1.4.1 1996/05/31 18:41:33 jtc Exp $ */
+/* $OpenBSD: check.c,v 1.4 1997/02/28 08:36:10 millert Exp $ */
+/* $NetBSD: check.c,v 1.6 1997/01/03 14:32:48 ws Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank
@@ -35,7 +35,7 @@
#ifndef lint
-static char rcsid[] = "$OpenBSD: check.c,v 1.3 1996/06/23 14:30:41 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: check.c,v 1.4 1997/02/28 08:36:10 millert Exp $";
#endif /* not lint */
#include <stdlib.h>
@@ -154,9 +154,15 @@ checkfilesys(fname)
free(fat);
close(dosfs);
- pwarn("%d files, %d free (%d clusters)\n",
- boot.NumFiles, boot.NumFree * boot.ClusterSize / 1024,
- boot.NumFree);
+ if (boot.NumBad)
+ pwarn("%d files, %d free (%d clusters), %d bad (%d clusters)\n",
+ boot.NumFiles,
+ boot.NumFree * boot.ClusterSize / 1024, boot.NumFree,
+ boot.NumBad * boot.ClusterSize / 1024, boot.NumBad);
+ else
+ pwarn("%d files, %d free (%d clusters)\n",
+ boot.NumFiles,
+ boot.NumFree * boot.ClusterSize / 1024, boot.NumFree);
if (mod & (FSFATAL | FSERROR))
return 8;
if (mod) {
diff --git a/sbin/fsck_msdos/dir.c b/sbin/fsck_msdos/dir.c
index 7a6133706a5..92b21c05f8e 100644
--- a/sbin/fsck_msdos/dir.c
+++ b/sbin/fsck_msdos/dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dir.c,v 1.5 1996/09/18 06:59:03 mickey Exp $ */
+/* $OpenBSD: dir.c,v 1.6 1997/02/28 08:36:11 millert Exp $ */
/* $NetBSD: dir.c,v 1.1.4.1 1996/05/31 18:41:38 jtc Exp $ */
/*
@@ -37,7 +37,7 @@
#ifndef lint
-static char rcsid[] = "$OpenBSD: dir.c,v 1.5 1996/09/18 06:59:03 mickey Exp $";
+static char rcsid[] = "$OpenBSD: dir.c,v 1.6 1997/02/28 08:36:11 millert Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -167,7 +167,7 @@ fullpath(dir)
break;
memcpy(cp, np, nl);
*--cp = '/';
- } while (dir = dir->parent);
+ } while ((dir = dir->parent));
if (dir != NULL && dir->parent != NULL)
*--cp = '?';
return cp;
@@ -238,7 +238,7 @@ finishDosDirSection()
}
pendingDirectories = 0;
for (d = rootDir; d; d = nd) {
- if (nd = d->child) {
+ if ((nd = d->child)) {
d->child = 0;
continue;
}
@@ -498,7 +498,7 @@ readDosDirSection(f, boot, fat, dir)
vallfn = p;
valcl = cl;
} else if (shortSum != p[13]
- || lidx != *p & LRNOMASK) {
+ || lidx != (*p & LRNOMASK)) {
if (!invlfn) {
invlfn = vallfn;
invcl = valcl;
diff --git a/sbin/fsck_msdos/dosfs.h b/sbin/fsck_msdos/dosfs.h
index 46b5c1cb6d3..25e04eb6123 100644
--- a/sbin/fsck_msdos/dosfs.h
+++ b/sbin/fsck_msdos/dosfs.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: dosfs.h,v 1.3 1996/06/23 14:30:42 deraadt Exp $ */
-/* $NetBSD: dosfs.h,v 1.1.4.1 1996/05/31 18:41:42 jtc Exp $ */
+/* $OpenBSD: dosfs.h,v 1.4 1997/02/28 08:36:11 millert Exp $ */
+/* $NetBSD: dosfs.h,v 1.4 1997/01/03 14:32:48 ws Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank
@@ -73,6 +73,7 @@ struct bootblock {
/* Now some statistics: */
u_int NumFiles; /* # of plain files */
u_int NumFree; /* # of free clusters */
+ u_int NumBad; /* # of bad clusters */
};
struct fatEntry {
diff --git a/sbin/fsck_msdos/fat.c b/sbin/fsck_msdos/fat.c
index 5fb69df70e9..0388ce22ed4 100644
--- a/sbin/fsck_msdos/fat.c
+++ b/sbin/fsck_msdos/fat.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: fat.c,v 1.3 1996/06/23 14:30:43 deraadt Exp $ */
-/* $NetBSD: fat.c,v 1.1.4.1 1996/05/31 18:41:50 jtc Exp $ */
+/* $OpenBSD: fat.c,v 1.4 1997/02/28 08:36:12 millert Exp $ */
+/* $NetBSD: fat.c,v 1.5 1997/01/03 14:32:49 ws Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank
@@ -35,7 +35,7 @@
#ifndef lint
-static char rcsid[] = "$OpenBSD: fat.c,v 1.3 1996/06/23 14:30:43 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: fat.c,v 1.4 1997/02/28 08:36:12 millert Exp $";
#endif /* not lint */
#include <stdlib.h>
@@ -46,6 +46,9 @@ static char rcsid[] = "$OpenBSD: fat.c,v 1.3 1996/06/23 14:30:43 deraadt Exp $";
#include "ext.h"
+static int checkclnum __P((struct bootblock *, int, cl_t, cl_t *));
+static int clustdiffer __P((cl_t, cl_t *, cl_t *, int));
+
/*
* Check a cluster number for valid value
*/
@@ -62,6 +65,10 @@ checkclnum(boot, fat, cl, next)
boot->NumFree++;
return FSOK;
}
+ if (*next == CLUST_BAD) {
+ boot->NumBad++;
+ return FSOK;
+ }
if (*next < CLUST_FIRST
|| (*next >= boot->NumClusters && *next < CLUST_EOFS)) {
pwarn("Cluster %d in FAT %d continues with %s cluster number %d\n",
@@ -94,7 +101,7 @@ readfat(fs, boot, no, fp)
int size;
int ret = FSOK;
- boot->NumFree = 0;
+ boot->NumFree = boot->NumBad = 0;
fat = malloc(sizeof(struct fatEntry) * boot->NumClusters);
buffer = malloc(boot->FATsecs * boot->BytesPerSec);
if (fat == NULL || buffer == NULL) {
@@ -318,9 +325,10 @@ checkfat(boot, fat)
* pass 1: figure out the cluster chains.
*/
for (head = CLUST_FIRST; head < boot->NumClusters; head++) {
- /* find next untraveled chain */
+ /* find next untraveled chain */
if (fat[head].head != 0 /* cluster already belongs to some chain*/
- || fat[head].next == CLUST_FREE)
+ || fat[head].next == CLUST_FREE
+ || fat[head].next == CLUST_BAD)
continue; /* skip it. */
/* follow the chain and mark all clusters on the way */