-/* $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
#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>
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) {
-/* $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 $ */
/*
#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>
break;
memcpy(cp, np, nl);
*--cp = '/';
- } while (dir = dir->parent);
+ } while ((dir = dir->parent));
if (dir != NULL && dir->parent != NULL)
*--cp = '?';
return cp;
}
pendingDirectories = 0;
for (d = rootDir; d; d = nd) {
- if (nd = d->child) {
+ if ((nd = d->child)) {
d->child = 0;
continue;
}
vallfn = p;
valcl = cl;
} else if (shortSum != p[13]
- || lidx != *p & LRNOMASK) {
+ || lidx != (*p & LRNOMASK)) {
if (!invlfn) {
invlfn = vallfn;
invcl = valcl;
-/* $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
/* Now some statistics: */
u_int NumFiles; /* # of plain files */
u_int NumFree; /* # of free clusters */
+ u_int NumBad; /* # of bad clusters */
};
struct fatEntry {
-/* $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
#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>
#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
*/
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",
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) {
* 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 */