1*17936Smckusick /* @(#)fsck.h 3.3 (Berkeley) 02/08/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 14*17936Smckusick #define USTATE 01 /* inode not allocated */ 15*17936Smckusick #define FSTATE 02 /* inode is file */ 16*17936Smckusick #define DSTATE 03 /* inode is directory */ 17*17936Smckusick #define DFOUND 04 /* directory found during descent */ 18*17936Smckusick #define DCLEAR 05 /* directory is to be cleared */ 19*17936Smckusick #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; 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 9116260Smckusick 9216260Smckusick daddr_t duplist[DUPTBLSIZE]; /* dup block table */ 9316260Smckusick daddr_t *enddup; /* next entry in dup table */ 9416260Smckusick daddr_t *muldup; /* multiple dups part of table */ 9516260Smckusick 9616260Smckusick ino_t badlncnt[MAXLNCNT]; /* table of inos with zero link cnts */ 9716260Smckusick ino_t *badlnp; /* next entry in table */ 9816260Smckusick 9916260Smckusick char rawflg; 10016260Smckusick char *devname; 10116260Smckusick char nflag; /* assume a no response */ 10216260Smckusick char yflag; /* assume a yes response */ 10316260Smckusick int bflag; /* location of alternate super block */ 10416260Smckusick int debug; /* output debugging info */ 10516260Smckusick char preen; /* just fix normal inconsistencies */ 10616260Smckusick char hotroot; /* checking root device */ 10716260Smckusick 10816260Smckusick char *blockmap; /* ptr to primary blk allocation map */ 10916260Smckusick char *statemap; /* ptr to inode state table */ 11016260Smckusick short *lncntp; /* ptr to link count table */ 11116260Smckusick 11216260Smckusick char pathname[BUFSIZ]; /* current pathname */ 11316260Smckusick char *pathp; /* pointer to pathname position */ 11416260Smckusick char *endpathname; 11516260Smckusick 11617930Smckusick daddr_t fmax; /* number of blocks in the volume */ 11716260Smckusick ino_t imax; /* number of inodes */ 11816260Smckusick ino_t lastino; /* hiwater mark of inodes */ 11917930Smckusick ino_t lfdir; /* lost & found directory inode number */ 12017930Smckusick char *lfname; /* lost & found directory name */ 12116260Smckusick 12216260Smckusick off_t maxblk; /* largest logical blk in file */ 12316260Smckusick off_t bmapsz; /* num chars in blockmap */ 12416260Smckusick 12516260Smckusick daddr_t n_blks; /* number of blocks used */ 12616260Smckusick daddr_t n_files; /* number of files seen */ 12716260Smckusick 12816260Smckusick #define zapino(x) (*(x) = zino) 12916260Smckusick struct dinode zino; 13016260Smckusick 13116260Smckusick #define setbmap(x) setbit(blockmap, x) 13216260Smckusick #define getbmap(x) isset(blockmap, x) 13316260Smckusick #define clrbmap(x) clrbit(blockmap, x) 13416260Smckusick 13516260Smckusick #define ALTERED 010 13616260Smckusick #define KEEPON 04 13716260Smckusick #define SKIP 02 13816260Smckusick #define STOP 01 13916260Smckusick 14016260Smckusick time_t time(); 14116260Smckusick DINODE *ginode(); 14216260Smckusick BUFAREA *getblk(); 14316260Smckusick int findino(); 144