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