1 /* @(#)fsck.h 3.3 (Berkeley) 02/08/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 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 108 char *blockmap; /* ptr to primary blk allocation map */ 109 char *statemap; /* ptr to inode state table */ 110 short *lncntp; /* ptr to link count table */ 111 112 char pathname[BUFSIZ]; /* current pathname */ 113 char *pathp; /* pointer to pathname position */ 114 char *endpathname; 115 116 daddr_t fmax; /* number of blocks in the volume */ 117 ino_t imax; /* number of inodes */ 118 ino_t lastino; /* hiwater mark of inodes */ 119 ino_t lfdir; /* lost & found directory inode number */ 120 char *lfname; /* lost & found directory name */ 121 122 off_t maxblk; /* largest logical blk in file */ 123 off_t bmapsz; /* num chars in blockmap */ 124 125 daddr_t n_blks; /* number of blocks used */ 126 daddr_t n_files; /* number of files seen */ 127 128 #define zapino(x) (*(x) = zino) 129 struct dinode zino; 130 131 #define setbmap(x) setbit(blockmap, x) 132 #define getbmap(x) isset(blockmap, x) 133 #define clrbmap(x) clrbit(blockmap, x) 134 135 #define ALTERED 010 136 #define KEEPON 04 137 #define SKIP 02 138 #define STOP 01 139 140 time_t time(); 141 DINODE *ginode(); 142 BUFAREA *getblk(); 143 int findino(); 144