-/* @(#)fsck.h 3.2 (Berkeley) %G% */
-
-/* RECONSTRUCT ONLY BAD CG IN PASS 6 */
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)fsck.h 5.6 (Berkeley) %G%
+ */
#define MAXDUP 10 /* limit on dup blks (per inode) */
#define MAXBAD 10 /* limit on bad blks (per inode) */
-#define DUPTBLSIZE 100 /* num of dup blocks to remember */
-#define MAXLNCNT 500 /* num zero link cnts to remember */
typedef int (*SIG_TYP)();
#define BUFSIZ 1024
#endif
-#define USTATE 0 /* inode not allocated */
-#define FSTATE 01 /* inode is file */
-#define DSTATE 02 /* inode is directory */
-#define CLEAR 03 /* inode is to be cleared */
+#define USTATE 01 /* inode not allocated */
+#define FSTATE 02 /* inode is file */
+#define DSTATE 03 /* inode is directory */
+#define DFOUND 04 /* directory found during descent */
+#define DCLEAR 05 /* directory is to be cleared */
+#define FCLEAR 06 /* file is to be cleared */
typedef struct dinode DINODE;
typedef struct direct DIRECT;
struct bufarea *b_next; /* must be first */
daddr_t b_bno;
int b_size;
+ int b_errs;
union {
char b_buf[MAXBSIZE]; /* buffer space */
short b_lnks[SPERB]; /* link counts */
#define DATA 1
#define ADDR 2
-
-daddr_t duplist[DUPTBLSIZE]; /* dup block table */
-daddr_t *enddup; /* next entry in dup table */
-daddr_t *muldup; /* multiple dups part of table */
-
-ino_t badlncnt[MAXLNCNT]; /* table of inos with zero link cnts */
-ino_t *badlnp; /* next entry in table */
+/*
+ * Linked list of duplicate blocks.
+ *
+ * The list is composed of two parts. The first part of the
+ * list (from duplist through the node pointed to by muldup)
+ * contains a single copy of each duplicate block that has been
+ * found. The second part of the list (from muldup to the end)
+ * contains duplicate blocks that have been found more than once.
+ * To check if a block has been found as a duplicate it is only
+ * necessary to search from duplist through muldup. To find the
+ * total number of times that a block has been found as a duplicate
+ * the entire list must be searched for occurences of the block
+ * in question. The following diagram shows a sample list where
+ * w (found twice), x (found once), y (found three times), and z
+ * (found once) are duplicate block numbers:
+ *
+ * w -> y -> x -> z -> y -> w -> y
+ * ^ ^
+ * | |
+ * duplist muldup
+ */
+struct dups {
+ struct dups *next;
+ daddr_t dup;
+};
+struct dups *duplist; /* head of dup list */
+struct dups *muldup; /* end of unique duplicate dup block numbers */
+
+/*
+ * Linked list of inodes with zero link counts.
+ */
+struct zlncnt {
+ struct zlncnt *next;
+ ino_t zlncnt;
+};
+struct zlncnt *zlnhead; /* head of zero link count list */
char rawflg;
char *devname;
+long dev_bsize; /* computed value of DEV_BSIZE */
+long secsize; /* actual disk sector size */
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bflag; /* location of alternate super block */
int debug; /* output debugging info */
+int cvtflag; /* convert to old file system format */
char preen; /* just fix normal inconsistencies */
char hotroot; /* checking root device */
-char fixcg; /* corrupted free list bit maps */
+char havesb; /* superblock has been read */
char *blockmap; /* ptr to primary blk allocation map */
-char *freemap; /* ptr to secondary blk allocation map */
char *statemap; /* ptr to inode state table */
short *lncntp; /* ptr to link count table */
off_t maxblk; /* largest logical blk in file */
off_t bmapsz; /* num chars in blockmap */
-daddr_t n_ffree; /* number of small free blocks */
-daddr_t n_bfree; /* number of large free blocks */
daddr_t n_blks; /* number of blocks used */
daddr_t n_files; /* number of files seen */
-daddr_t n_index;
-daddr_t n_bad;
-
-daddr_t badblk;
-daddr_t dupblk;
-
-int inosumbad;
-int offsumbad;
-int frsumbad;
-int sbsumbad;
#define zapino(x) (*(x) = zino)
struct dinode zino;
#define getbmap(x) isset(blockmap, x)
#define clrbmap(x) clrbit(blockmap, x)
-#define setfmap(x) setbit(freemap, x)
-#define getfmap(x) isset(freemap, x)
-#define clrfmap(x) clrbit(freemap, x)
-
+#define FOUND 020
#define ALTERED 010
#define KEEPON 04
#define SKIP 02