diff options
author | mckusick <mckusick@FreeBSD.org> | 2001-04-16 22:22:21 +0000 |
---|---|---|
committer | mckusick <mckusick@FreeBSD.org> | 2001-04-16 22:22:21 +0000 |
commit | 8553bca948638af0851ed308cfc71c940bbc179e (patch) | |
tree | 22d991906cdeef6ffaca97cddaf80f72161dae29 /sbin/fsck_ffs/setup.c | |
parent | 3b359dad32baa6f19fa388a452fd376f08bb28a6 (diff) | |
download | FreeBSD-src-8553bca948638af0851ed308cfc71c940bbc179e.zip FreeBSD-src-8553bca948638af0851ed308cfc71c940bbc179e.tar.gz |
Minor background cleanups:
1) Set the FS_NEEDSFSCK flag when unexpected problems are encountered.
2) Clear the FS_NEEDSFSCK flag after a successful foreground cleanup.
3) Refuse to run in background when the FS_NEEDSFSCK flag is set.
4) Avoid taking and removing a snapshot when the filesystem is already clean.
5) Properly implement the force cleaning (-f) flag when in preen mode.
Note that you need to have revision 1.21 (date: 2001/04/14 05:26:28) of
fs.h installed in <ufs/ffs/fs.h> defining FS_NEEDSFSCK for this to compile.
Diffstat (limited to 'sbin/fsck_ffs/setup.c')
-rw-r--r-- | sbin/fsck_ffs/setup.c | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index d8d77a5..517547d 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -62,7 +62,6 @@ struct bufarea asblk; static void badsb __P((int listerr, char *s)); static int calcsb __P((char *dev, int devfd, struct fs *fs)); static struct disklabel *getdisklabel __P((char *s, int fd)); -static int readsb __P((int listerr)); /* * Read in a superblock finding an alternate if necessary. @@ -74,8 +73,7 @@ setup(dev) char *dev; { long cg, size, asked, i, j; - long skipclean, bmapsize; - struct disklabel *lp; + long bmapsize; off_t sizepb; struct stat statb; struct fs proto; @@ -83,7 +81,6 @@ setup(dev) havesb = 0; fswritefd = -1; cursnapshot = 0; - skipclean = fflag ? 0 : preen; if (stat(dev, &statb) < 0) { printf("Can't stat %s: %s\n", dev, strerror(errno)); if (bkgrdflag) { @@ -160,18 +157,6 @@ setup(dev) } if (preen == 0) printf("\n"); - fsmodified = 0; - lfdir = 0; - initbarea(&sblk); - initbarea(&asblk); - sblk.b_un.b_buf = malloc(SBSIZE); - 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"); - if ((lp = getdisklabel(NULL, fsreadfd))) - dev_bsize = secsize = lp->d_secsize; - else - dev_bsize = secsize = DEV_BSIZE; /* * Read in the superblock, looking for alternates if necessary */ @@ -200,7 +185,7 @@ setup(dev) pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); bflag = 0; } - if (skipclean && sblock.fs_clean) { + if (skipclean && preen && sblock.fs_clean) { pwarn("FILESYSTEM CLEAN; SKIPPING CHECKS\n"); return (-1); } @@ -372,7 +357,7 @@ badsb: /* * Read in the super block and its summary info. */ -static int +int readsb(listerr) int listerr; { @@ -490,6 +475,25 @@ badsb(listerr, s) pfatal("BAD SUPER BLOCK: %s\n", s); } +sblock_init() +{ + struct disklabel *lp; + + fswritefd = -1; + fsmodified = 0; + lfdir = 0; + initbarea(&sblk); + initbarea(&asblk); + sblk.b_un.b_buf = malloc(SBSIZE); + 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"); + if ((lp = getdisklabel(NULL, fsreadfd))) + dev_bsize = secsize = lp->d_secsize; + else + dev_bsize = secsize = DEV_BSIZE; +} + /* * Calculate a prototype superblock based on information in the disk label. * When done the cgsblock macro can be calculated and the fs_ncg field |