/* @(#)fsck.h 3.1 (Berkeley) %G% */
/* RECONSTRUCT ONLY BAD CG IN PASS 6 */
#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 MAXNINDIR (MAXBSIZE / sizeof (daddr_t))
#define MAXINOPB (MAXBSIZE / sizeof (struct dinode))
#define SPERB (MAXBSIZE / sizeof(short))
#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 */
typedef struct dinode DINODE
;
typedef struct direct DIRECT
;
#define ALLOC ((dp->di_mode & IFMT) != 0)
#define DIRCT ((dp->di_mode & IFMT) == IFDIR)
#define SPECIAL ((dp->di_mode & IFMT) == IFBLK || (dp->di_mode & IFMT) == IFCHR)
struct bufarea
*b_next
; /* must be first */
char b_buf
[MAXBSIZE
]; /* buffer space */
short b_lnks
[SPERB
]; /* link counts */
daddr_t b_indir
[MAXNINDIR
]; /* indirect block */
struct fs b_fs
; /* super block */
struct cg b_cg
; /* cylinder group */
struct dinode b_dinode
[MAXINOPB
]; /* inode block */
typedef struct bufarea BUFAREA
;
BUFAREA inoblk
; /* inode blocks */
BUFAREA fileblk
; /* other blks in filesys */
BUFAREA sblk
; /* file system superblock */
BUFAREA cgblk
; /* cylinder group blocks */
#define initbarea(x) (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1
#define dirty(x) (x)->b_dirty = 1
#define inodirty() inoblk.b_dirty = 1
#define sbdirty() sblk.b_dirty = 1
#define cgdirty() cgblk.b_dirty = 1
#define dirblk fileblk.b_un
#define sblock sblk.b_un.b_fs
#define cgrp cgblk.b_un.b_cg
} dfile
; /* file descriptors for filesys */
char id_type
; /* type of descriptor, DATA or ADDR */
int (*id_func
)(); /* function to be applied to blocks of inode */
ino_t id_number
; /* inode number described */
ino_t id_parent
; /* for DATA nodes, their parent */
daddr_t id_blkno
; /* current block number being examined */
int id_numfrags
; /* number of frags contained in block */
long id_filesize
; /* for DATA nodes, the size of the directory */
int id_loc
; /* for DATA nodes, current location in dir */
int id_entryno
; /* for DATA nodes, current entry number */
DIRECT
*id_dirp
; /* for data nodes, ptr to current entry */
enum {DONTKNOW
, NOFIX
, FIX
} id_fix
; /* policy on fixing errors */
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 */
char nflag
; /* assume a no response */
char yflag
; /* assume a yes response */
int bflag
; /* location of alternate super block */
int debug
; /* output debugging info */
char preen
; /* just fix normal inconsistencies */
char rplyflag
; /* any questions asked? */
char hotroot
; /* checking root device */
char fixcg
; /* corrupted free list bit maps */
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 */
char *srchname
; /* name being searched for in dir */
char pathname
[BUFSIZ
]; /* current pathname */
char *pathp
; /* pointer to pathname position */
ino_t imax
; /* number of inodes */
ino_t lastino
; /* hiwater mark of inodes */
ino_t lfdir
; /* lost & found directory */
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 fmax
; /* number of blocks in the volume */
#define zapino(x) (*(x) = zino)
#define setbmap(x) setbit(blockmap, x)
#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)