summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_ffs/setup.c')
-rw-r--r--sbin/fsck_ffs/setup.c49
1 files changed, 17 insertions, 32 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c
index 25dab92..5a842f4 100644
--- a/sbin/fsck_ffs/setup.c
+++ b/sbin/fsck_ffs/setup.c
@@ -32,16 +32,13 @@
*/
#ifndef lint
-#if 0
static const char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
-#endif
-static const char rcsid[] =
- "$Id: setup.c,v 1.11 1998/06/15 07:07:21 charnier Exp $";
#endif /* not lint */
#define DKTYPENAMES
#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <sys/disklabel.h>
#include <sys/file.h>
@@ -82,7 +79,7 @@ setup(dev)
havesb = 0;
fswritefd = -1;
- skipclean = preen;
+ skipclean = fflag ? 0 : preen;
if (stat(dev, &statb) < 0) {
printf("Can't stat %s: %s\n", dev, strerror(errno));
return (0);
@@ -114,8 +111,7 @@ setup(dev)
asblk.b_un.b_buf = malloc(SBSIZE);
if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL)
errx(EEXIT, "cannot allocate space for superblock");
- lp = getdisklabel((char *)NULL, fsreadfd);
- if (lp)
+ if ((lp = getdisklabel(NULL, fsreadfd)))
dev_bsize = secsize = lp->d_secsize;
else
dev_bsize = secsize = DEV_BSIZE;
@@ -147,6 +143,10 @@ setup(dev)
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
bflag = 0;
}
+ if (skipclean && sblock.fs_clean) {
+ pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n");
+ return (-1);
+ }
maxfsblock = sblock.fs_size;
maxino = sblock.fs_ncg * sblock.fs_ipg;
/*
@@ -265,12 +265,6 @@ setup(dev)
}
}
/*
- * If we survive the above basic checks and are preening,
- * quit here unless forced.
- */
- if (skipclean && sblock.fs_clean && !fflag)
- return (-1);
- /*
* allocate and initialize the necessary maps
*/
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(short));
@@ -280,22 +274,11 @@ setup(dev)
(unsigned)bmapsize);
goto badsb;
}
- statemap = calloc((unsigned)(maxino + 1), sizeof(char));
- if (statemap == NULL) {
- printf("cannot alloc %u bytes for statemap\n",
- (unsigned)(maxino + 1));
- goto badsb;
- }
- typemap = calloc((unsigned)(maxino + 1), sizeof(char));
- if (typemap == NULL) {
- printf("cannot alloc %u bytes for typemap\n",
- (unsigned)(maxino + 1));
- goto badsb;
- }
- lncntp = (short *)calloc((unsigned)(maxino + 1), sizeof(short));
- if (lncntp == NULL) {
- printf("cannot alloc %u bytes for lncntp\n",
- (unsigned)(maxino + 1) * sizeof(short));
+ inostathead = calloc((unsigned)(sblock.fs_ncg),
+ sizeof(struct inostatlist));
+ if (inostathead == NULL) {
+ printf("cannot alloc %u bytes for inostathead\n",
+ (unsigned)(sizeof(struct inostatlist) * (sblock.fs_ncg)));
goto badsb;
}
numdirs = sblock.fs_cstotal.cs_ndir;
@@ -474,9 +457,11 @@ calcsb(dev, devfd, fs)
fstypenames[pp->p_fstype] : "unknown");
return (0);
}
- if (pp->p_fsize == 0 || pp->p_frag == 0) {
- pfatal("%s: LABELED AS A %s FILE SYSTEM, BUT BLOCK SIZE IS 0\n",
- dev, fstypenames[pp->p_fstype]);
+ if (pp->p_fsize == 0 || pp->p_frag == 0 ||
+ pp->p_cpg == 0 || pp->p_size == 0) {
+ pfatal("%s: %s: type %s fsize %d, frag %d, cpg %d, size %d\n",
+ dev, "INCOMPLETE LABEL", fstypenames[pp->p_fstype],
+ pp->p_fsize, pp->p_frag, pp->p_cpg, pp->p_size);
return (0);
}
memset(fs, 0, sizeof(struct fs));
OpenPOWER on IntegriCloud