1*21743Smckusick /* @(#)fsck.h 3.5 (Berkeley) 05/31/85 */ 216260Smckusick 316260Smckusick #define MAXDUP 10 /* limit on dup blks (per inode) */ 416260Smckusick #define MAXBAD 10 /* limit on bad blks (per inode) */ 516260Smckusick #define MAXLNCNT 500 /* num zero link cnts to remember */ 616260Smckusick 716260Smckusick typedef int (*SIG_TYP)(); 816260Smckusick 916260Smckusick #ifndef BUFSIZ 1016260Smckusick #define BUFSIZ 1024 1116260Smckusick #endif 1216260Smckusick 1317936Smckusick #define USTATE 01 /* inode not allocated */ 1417936Smckusick #define FSTATE 02 /* inode is file */ 1517936Smckusick #define DSTATE 03 /* inode is directory */ 1617936Smckusick #define DFOUND 04 /* directory found during descent */ 1717936Smckusick #define DCLEAR 05 /* directory is to be cleared */ 1817936Smckusick #define FCLEAR 06 /* file is to be cleared */ 1916260Smckusick 2016260Smckusick typedef struct dinode DINODE; 2116260Smckusick typedef struct direct DIRECT; 2216260Smckusick 2317930Smckusick #define ALLOC(dip) (((dip)->di_mode & IFMT) != 0) 2417930Smckusick #define DIRCT(dip) (((dip)->di_mode & IFMT) == IFDIR) 2517930Smckusick #define SPECIAL(dip) \ 2617930Smckusick (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR) 2716260Smckusick 2817930Smckusick #define MAXNINDIR (MAXBSIZE / sizeof (daddr_t)) 2917930Smckusick #define MAXINOPB (MAXBSIZE / sizeof (struct dinode)) 3017930Smckusick #define SPERB (MAXBSIZE / sizeof(short)) 3117930Smckusick 3216260Smckusick struct bufarea { 3316260Smckusick struct bufarea *b_next; /* must be first */ 3416260Smckusick daddr_t b_bno; 3516260Smckusick int b_size; 3621540Smckusick int b_errs; 3716260Smckusick union { 3816260Smckusick char b_buf[MAXBSIZE]; /* buffer space */ 3916260Smckusick short b_lnks[SPERB]; /* link counts */ 4016260Smckusick daddr_t b_indir[MAXNINDIR]; /* indirect block */ 4116260Smckusick struct fs b_fs; /* super block */ 4216260Smckusick struct cg b_cg; /* cylinder group */ 4316260Smckusick struct dinode b_dinode[MAXINOPB]; /* inode block */ 4416260Smckusick } b_un; 4516260Smckusick char b_dirty; 4616260Smckusick }; 4716260Smckusick 4816260Smckusick typedef struct bufarea BUFAREA; 4916260Smckusick 5016260Smckusick BUFAREA inoblk; /* inode blocks */ 5116260Smckusick BUFAREA fileblk; /* other blks in filesys */ 5216260Smckusick BUFAREA sblk; /* file system superblock */ 5316260Smckusick BUFAREA cgblk; /* cylinder group blocks */ 5416260Smckusick 5516260Smckusick #define initbarea(x) (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1 5616260Smckusick #define dirty(x) (x)->b_dirty = 1 5716260Smckusick #define inodirty() inoblk.b_dirty = 1 5816260Smckusick #define sbdirty() sblk.b_dirty = 1 5916260Smckusick #define cgdirty() cgblk.b_dirty = 1 6016260Smckusick 6116260Smckusick #define dirblk fileblk.b_un 6216260Smckusick #define sblock sblk.b_un.b_fs 6316260Smckusick #define cgrp cgblk.b_un.b_cg 6416260Smckusick 6516260Smckusick struct filecntl { 6616260Smckusick int rfdes; 6716260Smckusick int wfdes; 6816260Smckusick int mod; 6916260Smckusick } dfile; /* file descriptors for filesys */ 7016260Smckusick 7117930Smckusick enum fixstate {DONTKNOW, NOFIX, FIX}; 7217930Smckusick 7316260Smckusick struct inodesc { 7417930Smckusick enum fixstate id_fix; /* policy on fixing errors */ 7516260Smckusick int (*id_func)(); /* function to be applied to blocks of inode */ 7616260Smckusick ino_t id_number; /* inode number described */ 7716260Smckusick ino_t id_parent; /* for DATA nodes, their parent */ 7816260Smckusick daddr_t id_blkno; /* current block number being examined */ 7916260Smckusick int id_numfrags; /* number of frags contained in block */ 8016260Smckusick long id_filesize; /* for DATA nodes, the size of the directory */ 8116260Smckusick int id_loc; /* for DATA nodes, current location in dir */ 8216260Smckusick int id_entryno; /* for DATA nodes, current entry number */ 8317930Smckusick DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */ 8417930Smckusick char *id_name; /* for DATA nodes, name to find or enter */ 8517930Smckusick char id_type; /* type of descriptor, DATA or ADDR */ 8616260Smckusick }; 8716260Smckusick /* file types */ 8816260Smckusick #define DATA 1 8916260Smckusick #define ADDR 2 9016260Smckusick 91*21743Smckusick /* 92*21743Smckusick * Linked list of duplicate blocks 93*21743Smckusick */ 94*21743Smckusick struct dups { 95*21743Smckusick struct dups *next; 96*21743Smckusick daddr_t dup; 97*21743Smckusick }; 98*21743Smckusick struct dups *duplist; /* head of dup list */ 99*21743Smckusick struct dups *muldup; /* end of unique duplicate dup block numbers */ 10016260Smckusick 10116260Smckusick ino_t badlncnt[MAXLNCNT]; /* table of inos with zero link cnts */ 10216260Smckusick ino_t *badlnp; /* next entry in table */ 10316260Smckusick 10416260Smckusick char rawflg; 10516260Smckusick char *devname; 10616260Smckusick char nflag; /* assume a no response */ 10716260Smckusick char yflag; /* assume a yes response */ 10816260Smckusick int bflag; /* location of alternate super block */ 10916260Smckusick int debug; /* output debugging info */ 11016260Smckusick char preen; /* just fix normal inconsistencies */ 11116260Smckusick char hotroot; /* checking root device */ 11216260Smckusick 11316260Smckusick char *blockmap; /* ptr to primary blk allocation map */ 11416260Smckusick char *statemap; /* ptr to inode state table */ 11516260Smckusick short *lncntp; /* ptr to link count table */ 11616260Smckusick 11716260Smckusick char pathname[BUFSIZ]; /* current pathname */ 11816260Smckusick char *pathp; /* pointer to pathname position */ 11916260Smckusick char *endpathname; 12016260Smckusick 12117930Smckusick daddr_t fmax; /* number of blocks in the volume */ 12216260Smckusick ino_t imax; /* number of inodes */ 12316260Smckusick ino_t lastino; /* hiwater mark of inodes */ 12417930Smckusick ino_t lfdir; /* lost & found directory inode number */ 12517930Smckusick char *lfname; /* lost & found directory name */ 12616260Smckusick 12716260Smckusick off_t maxblk; /* largest logical blk in file */ 12816260Smckusick off_t bmapsz; /* num chars in blockmap */ 12916260Smckusick 13016260Smckusick daddr_t n_blks; /* number of blocks used */ 13116260Smckusick daddr_t n_files; /* number of files seen */ 13216260Smckusick 13316260Smckusick #define zapino(x) (*(x) = zino) 13416260Smckusick struct dinode zino; 13516260Smckusick 13616260Smckusick #define setbmap(x) setbit(blockmap, x) 13716260Smckusick #define getbmap(x) isset(blockmap, x) 13816260Smckusick #define clrbmap(x) clrbit(blockmap, x) 13916260Smckusick 14016260Smckusick #define ALTERED 010 14116260Smckusick #define KEEPON 04 14216260Smckusick #define SKIP 02 14316260Smckusick #define STOP 01 14416260Smckusick 14516260Smckusick time_t time(); 14616260Smckusick DINODE *ginode(); 14716260Smckusick BUFAREA *getblk(); 14816260Smckusick int findino(); 149