1 /* @(#)fsck.h 3.4 (Berkeley) 05/31/85 */ 2 3 #define MAXDUP 10 /* limit on dup blks (per inode) */ 4 #define MAXBAD 10 /* limit on bad blks (per inode) */ 5 #define DUPTBLSIZE 100 /* num of dup blocks to remember */ 6 #define MAXLNCNT 500 /* num zero link cnts to remember */ 7 8 typedef int (*SIG_TYP)(); 9 10 #ifndef BUFSIZ 11 #define BUFSIZ 1024 12 #endif 13 14 #define USTATE 01 /* inode not allocated */ 15 #define FSTATE 02 /* inode is file */ 16 #define DSTATE 03 /* inode is directory */ 17 #define DFOUND 04 /* directory found during descent */ 18 #define DCLEAR 05 /* directory is to be cleared */ 19 #define FCLEAR 06 /* file is to be cleared */ 20 21 typedef struct dinode DINODE; 22 typedef struct direct DIRECT; 23 24 #define ALLOC(dip) (((dip)->di_mode & IFMT) != 0) 25 #define DIRCT(dip) (((dip)->di_mode & IFMT) == IFDIR) 26 #define SPECIAL(dip) \ 27 (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR) 28 29 #define MAXNINDIR (MAXBSIZE / sizeof (daddr_t)) 30 #define MAXINOPB (MAXBSIZE / sizeof (struct dinode)) 31 #define SPERB (MAXBSIZE / sizeof(short)) 32 33 struct bufarea { 34 struct bufarea *b_next; /* must be first */ 35 daddr_t b_bno; 36 int b_size; 37 int b_errs; 38 union { 39 char b_buf[MAXBSIZE]; /* buffer space */ 40 short b_lnks[SPERB]; /* link counts */ 41 daddr_t b_indir[MAXNINDIR]; /* indirect block */ 42 struct fs b_fs; /* super block */ 43 struct cg b_cg; /* cylinder group */ 44 struct dinode b_dinode[MAXINOPB]; /* inode block */ 45 } b_un; 46 char b_dirty; 47 }; 48 49 typedef struct bufarea BUFAREA; 50 51 BUFAREA inoblk; /* inode blocks */ 52 BUFAREA fileblk; /* other blks in filesys */ 53 BUFAREA sblk; /* file system superblock */ 54 BUFAREA cgblk; /* cylinder group blocks */ 55 56 #define initbarea(x) (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1 57 #define dirty(x) (x)->b_dirty = 1 58 #define inodirty() inoblk.b_dirty = 1 59 #define sbdirty() sblk.b_dirty = 1 60 #define cgdirty() cgblk.b_dirty = 1 61 62 #define dirblk fileblk.b_un 63 #define sblock sblk.b_un.b_fs 64 #define cgrp cgblk.b_un.b_cg 65 66 struct filecntl { 67 int rfdes; 68 int wfdes; 69 int mod; 70 } dfile; /* file descriptors for filesys */ 71 72 enum fixstate {DONTKNOW, NOFIX, FIX}; 73 74 struct inodesc { 75 enum fixstate id_fix; /* policy on fixing errors */ 76 int (*id_func)(); /* function to be applied to blocks of inode */ 77 ino_t id_number; /* inode number described */ 78 ino_t id_parent; /* for DATA nodes, their parent */ 79 daddr_t id_blkno; /* current block number being examined */ 80 int id_numfrags; /* number of frags contained in block */ 81 long id_filesize; /* for DATA nodes, the size of the directory */ 82 int id_loc; /* for DATA nodes, current location in dir */ 83 int id_entryno; /* for DATA nodes, current entry number */ 84 DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */ 85 char *id_name; /* for DATA nodes, name to find or enter */ 86 char id_type; /* type of descriptor, DATA or ADDR */ 87 }; 88 /* file types */ 89 #define DATA 1 90 #define ADDR 2 91 92 93 daddr_t duplist[DUPTBLSIZE]; /* dup block table */ 94 daddr_t *enddup; /* next entry in dup table */ 95 daddr_t *muldup; /* multiple dups part of table */ 96 97 ino_t badlncnt[MAXLNCNT]; /* table of inos with zero link cnts */ 98 ino_t *badlnp; /* next entry in table */ 99 100 char rawflg; 101 char *devname; 102 char nflag; /* assume a no response */ 103 char yflag; /* assume a yes response */ 104 int bflag; /* location of alternate super block */ 105 int debug; /* output debugging info */ 106 char preen; /* just fix normal inconsistencies */ 107 char hotroot; /* checking root device */ 108 109 char *blockmap; /* ptr to primary blk allocation map */ 110 char *statemap; /* ptr to inode state table */ 111 short *lncntp; /* ptr to link count table */ 112 113 char pathname[BUFSIZ]; /* current pathname */ 114 char *pathp; /* pointer to pathname position */ 115 char *endpathname; 116 117 daddr_t fmax; /* number of blocks in the volume */ 118 ino_t imax; /* number of inodes */ 119 ino_t lastino; /* hiwater mark of inodes */ 120 ino_t lfdir; /* lost & found directory inode number */ 121 char *lfname; /* lost & found directory name */ 122 123 off_t maxblk; /* largest logical blk in file */ 124 off_t bmapsz; /* num chars in blockmap */ 125 126 daddr_t n_blks; /* number of blocks used */ 127 daddr_t n_files; /* number of files seen */ 128 129 #define zapino(x) (*(x) = zino) 130 struct dinode zino; 131 132 #define setbmap(x) setbit(blockmap, x) 133 #define getbmap(x) isset(blockmap, x) 134 #define clrbmap(x) clrbit(blockmap, x) 135 136 #define ALTERED 010 137 #define KEEPON 04 138 #define SKIP 02 139 #define STOP 01 140 141 time_t time(); 142 DINODE *ginode(); 143 BUFAREA *getblk(); 144 int findino(); 145