summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/suj.c
diff options
context:
space:
mode:
authorscottl <scottl@FreeBSD.org>2013-12-30 01:16:08 +0000
committerscottl <scottl@FreeBSD.org>2013-12-30 01:16:08 +0000
commitf0d9289d4bc1cea75e6ade6e0b1496020b81d254 (patch)
tree3f5b4ba557bcb5004e79798d6d96972dfe7d2e45 /sbin/fsck_ffs/suj.c
parent3652e600422dfba0018864e0430f86f9fae07bbd (diff)
downloadFreeBSD-src-f0d9289d4bc1cea75e6ade6e0b1496020b81d254.zip
FreeBSD-src-f0d9289d4bc1cea75e6ade6e0b1496020b81d254.tar.gz
Add the -R option to allow fsck_ffs to restart itself when too many critical
errors have been detected in a particular run. Clean up the global state variables so that a restart can happen correctly. Separate the global variables in fsck_ffs and fsdb to their own file. This fixes header sharing with fscd. Correctly initialize, static-ize, and remove global variables as needed in dir.c. This fixes a problem with lost+found directories that was causing a segfault. Correctly initialize, static-ize, and remove global variables as needed in suj.c. Initialize the suj globals before allocating the disk object, not after. Also ensure that 'preen' mode doesn't conflict with 'restart' mode Submitted by: scottl, max Reviewed by: max, mckusick (earlier version) Obtained from: Netflix MFC after: 3 days
Diffstat (limited to 'sbin/fsck_ffs/suj.c')
-rw-r--r--sbin/fsck_ffs/suj.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index 5fca0f5..9d6a2ec 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -125,26 +125,26 @@ struct suj_cg {
int sc_cgx;
};
-LIST_HEAD(cghd, suj_cg) cghash[SUJ_HASHSIZE];
-LIST_HEAD(dblkhd, data_blk) dbhash[SUJ_HASHSIZE];
-struct suj_cg *lastcg;
-struct data_blk *lastblk;
+static LIST_HEAD(cghd, suj_cg) cghash[SUJ_HASHSIZE];
+static LIST_HEAD(dblkhd, data_blk) dbhash[SUJ_HASHSIZE];
+static struct suj_cg *lastcg;
+static struct data_blk *lastblk;
-TAILQ_HEAD(seghd, suj_seg) allsegs;
-uint64_t oldseq;
+static TAILQ_HEAD(seghd, suj_seg) allsegs;
+static uint64_t oldseq;
static struct uufsd *disk = NULL;
static struct fs *fs = NULL;
-ino_t sujino;
+static ino_t sujino;
/*
* Summary statistics.
*/
-uint64_t freefrags;
-uint64_t freeblocks;
-uint64_t freeinos;
-uint64_t freedir;
-uint64_t jbytes;
-uint64_t jrecs;
+static uint64_t freefrags;
+static uint64_t freeblocks;
+static uint64_t freeinos;
+static uint64_t freedir;
+static uint64_t jbytes;
+static uint64_t jrecs;
static jmp_buf jmpbuf;
@@ -155,6 +155,7 @@ static void ino_decr(ino_t);
static void ino_adjust(struct suj_ino *);
static void ino_build(struct suj_ino *);
static int blk_isfree(ufs2_daddr_t);
+static void initsuj(void);
static void *
errmalloc(size_t n)
@@ -2413,7 +2414,7 @@ struct jextent {
int je_blocks; /* Disk block count. */
};
-struct jblocks *suj_jblocks;
+static struct jblocks *suj_jblocks;
static struct jblocks *
jblocks_create(void)
@@ -2673,8 +2674,8 @@ suj_check(const char *filesys)
struct suj_seg *seg;
struct suj_seg *segn;
+ initsuj();
opendisk(filesys);
- TAILQ_INIT(&allsegs);
/*
* Set an exit point when SUJ check failed
@@ -2763,3 +2764,28 @@ suj_check(const char *filesys)
return (0);
}
+
+static void
+initsuj(void)
+{
+ int i;
+
+ for (i = 0; i < SUJ_HASHSIZE; i++) {
+ LIST_INIT(&cghash[i]);
+ LIST_INIT(&dbhash[i]);
+ }
+ lastcg = NULL;
+ lastblk = NULL;
+ TAILQ_INIT(&allsegs);
+ oldseq = 0;
+ disk = NULL;
+ fs = NULL;
+ sujino = 0;
+ freefrags = 0;
+ freeblocks = 0;
+ freeinos = 0;
+ freedir = 0;
+ jbytes = 0;
+ jrecs = 0;
+ suj_jblocks = NULL;
+}
OpenPOWER on IntegriCloud