1 /* @(#)fsck.h 3.2 (Berkeley) 02/07/85 */ 2 3 /* RECONSTRUCT ONLY BAD CG IN PASS 6 */ 4 5 #define MAXDUP 10 /* limit on dup blks (per inode) */ 6 #define MAXBAD 10 /* limit on bad blks (per inode) */ 7 #define DUPTBLSIZE 100 /* num of dup blocks to remember */ 8 #define MAXLNCNT 500 /* num zero link cnts to remember */ 9 10 typedef int (*SIG_TYP)(); 11 12 #ifndef BUFSIZ 13 #define BUFSIZ 1024 14 #endif 15 16 #define USTATE 0 /* inode not allocated */ 17 #define FSTATE 01 /* inode is file */ 18 #define DSTATE 02 /* inode is directory */ 19 #define CLEAR 03 /* inode 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 union { 38 char b_buf[MAXBSIZE]; /* buffer space */ 39 short b_lnks[SPERB]; /* link counts */ 40 daddr_t b_indir[MAXNINDIR]; /* indirect block */ 41 struct fs b_fs; /* super block */ 42 struct cg b_cg; /* cylinder group */ 43 struct dinode b_dinode[MAXINOPB]; /* inode block */ 44 } b_un; 45 char b_dirty; 46 }; 47 48 typedef struct bufarea BUFAREA; 49 50 BUFAREA inoblk; /* inode blocks */ 51 BUFAREA fileblk; /* other blks in filesys */ 52 BUFAREA sblk; /* file system superblock */ 53 BUFAREA cgblk; /* cylinder group blocks */ 54 55 #define initbarea(x) (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1 56 #define dirty(x) (x)->b_dirty = 1 57 #define inodirty() inoblk.b_dirty = 1 58 #define sbdirty() sblk.b_dirty = 1 59 #define cgdirty() cgblk.b_dirty = 1 60 61 #define dirblk fileblk.b_un 62 #define sblock sblk.b_un.b_fs 63 #define cgrp cgblk.b_un.b_cg 64 65 struct filecntl { 66 int rfdes; 67 int wfdes; 68 int mod; 69 } dfile; /* file descriptors for filesys */ 70 71 enum fixstate {DONTKNOW, NOFIX, FIX}; 72 73 struct inodesc { 74 enum fixstate id_fix; /* policy on fixing errors */ 75 int (*id_func)(); /* function to be applied to blocks of inode */ 76 ino_t id_number; /* inode number described */ 77 ino_t id_parent; /* for DATA nodes, their parent */ 78 daddr_t id_blkno; /* current block number being examined */ 79 int id_numfrags; /* number of frags contained in block */ 80 long id_filesize; /* for DATA nodes, the size of the directory */ 81 int id_loc; /* for DATA nodes, current location in dir */ 82 int id_entryno; /* for DATA nodes, current entry number */ 83 DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */ 84 char *id_name; /* for DATA nodes, name to find or enter */ 85 char id_type; /* type of descriptor, DATA or ADDR */ 86 }; 87 /* file types */ 88 #define DATA 1 89 #define ADDR 2 90 91 92 daddr_t duplist[DUPTBLSIZE]; /* dup block table */ 93 daddr_t *enddup; /* next entry in dup table */ 94 daddr_t *muldup; /* multiple dups part of table */ 95 96 ino_t badlncnt[MAXLNCNT]; /* table of inos with zero link cnts */ 97 ino_t *badlnp; /* next entry in table */ 98 99 char rawflg; 100 char *devname; 101 char nflag; /* assume a no response */ 102 char yflag; /* assume a yes response */ 103 int bflag; /* location of alternate super block */ 104 int debug; /* output debugging info */ 105 char preen; /* just fix normal inconsistencies */ 106 char hotroot; /* checking root device */ 107 char fixcg; /* corrupted free list bit maps */ 108 109 char *blockmap; /* ptr to primary blk allocation map */ 110 char *freemap; /* ptr to secondary blk allocation map */ 111 char *statemap; /* ptr to inode state table */ 112 short *lncntp; /* ptr to link count table */ 113 114 char pathname[BUFSIZ]; /* current pathname */ 115 char *pathp; /* pointer to pathname position */ 116 char *endpathname; 117 118 daddr_t fmax; /* number of blocks in the volume */ 119 ino_t imax; /* number of inodes */ 120 ino_t lastino; /* hiwater mark of inodes */ 121 ino_t lfdir; /* lost & found directory inode number */ 122 char *lfname; /* lost & found directory name */ 123 124 off_t maxblk; /* largest logical blk in file */ 125 off_t bmapsz; /* num chars in blockmap */ 126 127 daddr_t n_ffree; /* number of small free blocks */ 128 daddr_t n_bfree; /* number of large free blocks */ 129 daddr_t n_blks; /* number of blocks used */ 130 daddr_t n_files; /* number of files seen */ 131 daddr_t n_index; 132 daddr_t n_bad; 133 134 daddr_t badblk; 135 daddr_t dupblk; 136 137 int inosumbad; 138 int offsumbad; 139 int frsumbad; 140 int sbsumbad; 141 142 #define zapino(x) (*(x) = zino) 143 struct dinode zino; 144 145 #define setbmap(x) setbit(blockmap, x) 146 #define getbmap(x) isset(blockmap, x) 147 #define clrbmap(x) clrbit(blockmap, x) 148 149 #define setfmap(x) setbit(freemap, x) 150 #define getfmap(x) isset(freemap, x) 151 #define clrfmap(x) clrbit(freemap, x) 152 153 #define ALTERED 010 154 #define KEEPON 04 155 #define SKIP 02 156 #define STOP 01 157 158 time_t time(); 159 DINODE *ginode(); 160 BUFAREA *getblk(); 161 int findino(); 162