|
|
1.1 ! root 1: /* ! 2: * Header file for fsck -- File System Check Program ! 3: * ! 4: */ ! 5: ! 6: #include <canon.h> ! 7: #include <sys/dir.h> ! 8: #include <sys/fblk.h> ! 9: #include <sys/filsys.h> ! 10: #include <sys/ino.h> ! 11: #include <sys/stat.h> ! 12: #include <sys/types.h> ! 13: #include <time.h> ! 14: ! 15: #if _I386 ! 16: #define SMALLMODEL 0 ! 17: #else ! 18: #define SMALLMODEL 1 ! 19: #endif ! 20: ! 21: #if HPCOHERENT ! 22: typedef long fsize_t; ! 23: #endif ! 24: ! 25: /* ! 26: * Conditional Compilation Flags ! 27: */ ! 28: ! 29: #define NOT_ALL_ZERO_INODE /* Dependent on whether or not an inode */ ! 30: #ifdef ALL_ZERO_INODE /* is totally zeroed when unallocated */ ! 31: #undef ALL_ZERO_INODE /* or simply a zero mode and zero link */ ! 32: #endif ! 33: ! 34: ! 35: /* ! 36: * Definitions and Externs ! 37: */ ! 38: ! 39: #define NUL 0 /* true zero ! */ ! 40: #define NULL ((char *)0) ! 41: ! 42: #define YES 3 /* default actions */ ! 43: #define NO 2 ! 44: #define ASK 1 ! 45: ! 46: #define NFILSYS 10 /* max number of file systems */ ! 47: #define MAXCH 20 /* max length of filesys name */ ! 48: ! 49: #define MAXBADOK 10 /* Max number of bad blocks before excessive */ ! 50: extern int numbad; /* num bad blocks found so far this inode*/ ! 51: ! 52: #define MAXDUPOK 10 /* Max number of dup blocks */ ! 53: /* in a single inode before excessive */ ! 54: #define DUPTBLSIZE 20 /* Max number of dup referenced blocks */ ! 55: extern daddr_t dupblck[]; /* table of duplicate referenced blocks */ ! 56: extern int totdups; /* number of dup blocks found so far */ ! 57: ! 58: #define MAXBADFREE 10 /* max bad in free list before abort */ ! 59: #define MAXDUPFREE 10 /* max dup in free list before abort */ ! 60: ! 61: #define GOOD 1 /* returned by bad() in util.c */ ! 62: #define BAD 0 ! 63: ! 64: #define TRUE 1 /* errflag possibilities */ ! 65: #define FALSE 0 ! 66: extern int errflag; /* errflag indicates not to do phases */ ! 67: ! 68: #define OK 1 /* used to indicate excessive bad/dup */ ! 69: #define STOP 0 /* blocks in an inode in phase1.c */ ! 70: #define BAD_DUP 2 ! 71: ! 72: #define FIRSTIN 2 /* First real inode number */ ! 73: ! 74: #define ND 10 /* Number of Direct Blocks */ ! 75: #undef NI ! 76: #define NI 1 ! 77: #define NII 1 ! 78: #define NIII 1 ! 79: #undef NADDR ! 80: #define NADDR (ND+NI+NII+NIII) ! 81: extern int offsets[]; /* table of offsets for level of indirection */ ! 82: /* for the blocks in an inode */ ! 83: ! 84: extern char nextchar(); /* used in util.c */ ! 85: extern int fsfd; /* file system file descriptor */ ! 86: extern int mdaction; /* default action for this invocation */ ! 87: extern int daction; /* default action for current file system */ ! 88: extern int writeflg; /* system write ok or read-only */ ! 89: extern int qflag; /* quiet fsck flag */ ! 90: extern int fflag; /* fast fsck flag */ ! 91: extern int sflag; /* force free list salvation */ ! 92: extern daddr_t fsize; /* file system size in blocks */ ! 93: extern int isize; /* first block not in inode list */ ! 94: /* isize is NOT unsigned so that comparisons */ ! 95: /* with longs will not cast the long to */ ! 96: /* unsigned thus producing confusing results */ ! 97: ! 98: extern daddr_t totfree; /* running count of total free blocks */ ! 99: extern unsigned ninodes;/* Number of inodes in the files system */ ! 100: extern char *fsname; /* file system name */ ! 101: extern fsize_t pinfo(); /* returns size of file, in phase2.c */ ! 102: extern ino_t lostfound(); /* returns inumber of lost+found dir */ ! 103: extern struct dinode *ptrino(); /* returns a ptr to inode, give number */ ! 104: extern char databuf[]; /* buffer to read in block, used throughout */ ! 105: extern char buf2[]; /* alternate data buffer */ ! 106: extern daddr_t cdbn; /* current block number, used by nextblock() */ ! 107: #define DSIZE (sizeof(struct direct)) ! 108: extern char *lostname; /* name of lost+found directory */ ! 109: extern char *nameit(); /* nameing function for lost dirs and files */ ! 110: extern int depth; /* used during tree traversal in phase2.c */ ! 111: extern struct direct *path[]; /* used during tree traversal in phase2.c */ ! 112: extern char *typename(); /* return string to type of inode */ ! 113: extern struct filsys *sbp; /* Super Block */ ! 114: extern int sbpfix; /* flag for super block fixes */ ! 115: extern struct stat stats; /* used by statit() in util.c */ ! 116: extern dev_t rootdev; /* root device number */ ! 117: extern dev_t fsysrdev; /* file system real device number */ ! 118: extern int mounted; /* flag indicating mountedness of filesystem */ ! 119: extern int changeflg; /* file system modified flag */ ! 120: extern int fixerup; /* flag to rebuild free list */ ! 121: extern char *fixit; /* Prompt message phase[45].c */ ! 122: extern int numfiles; /* num files in system */ ! 123: extern daddr_t imap(); /* function for disk block mapping in util.c */ ! 124: extern fsize_t lostsize; /* Size of files cleared in phase4.c */ ! 125: extern char *tmpfile; /* TMP File name for virtual.c */ ! 126: ! 127: #define SUCCESS 1 /* used in connect() in phase3.c */ ! 128: #define FAILURE 0 ! 129: ! 130: #define MODEMASK 0x07 ! 131: #define ALLOCMASK 0x06 ! 132: #define UNALLOC 0x00 ! 133: #define UNKNOWN 0x01 ! 134: #define IDIR 0x02 ! 135: #define IREG 0x03 ! 136: #define ICHR 0x04 ! 137: #define IBLK 0x05 ! 138: #define IPIPE 0x06 ! 139: #define IBAD_IDUP 0x08 ! 140: #define VISITED 0x10 ! 141: #define UNREFDIR 0x20 ! 142: #define CHILDDIR 0x40 ! 143: #define IFREELIST 0x80 ! 144: ! 145: /* ! 146: * Macros for tables ! 147: */ ! 148: ! 149: #if SMALLMODEL ! 150: /* Actions for virtual block system */ ! 151: enum vact { testBlock, markBlock, unmarkBlock, grabBlock, ! 152: testDup, markDup, unmarkDup, setDup, ! 153: Flags, setFlags, orFlags, ! 154: linkCtr, incLinkctr, setLinkctr }; ! 155: ! 156: #define testblock(bn) findblock((unsigned long)(bn), testBlock) ! 157: #define markblock(bn) findblock((unsigned long)(bn), markBlock) ! 158: #define unmarkblock(bn) findblock((unsigned long)(bn), unmarkBlock) ! 159: ! 160: #define testdup(bn) findblock((unsigned long)(bn), testDup) ! 161: #define markdup(bn) findblock((unsigned long)(bn), markDup) ! 162: #define unmarkdup(bn) findblock((unsigned long)(bn), unmarkDup) ! 163: ! 164: #define flags(ino) findblock((unsigned long)(ino), Flags) ! 165: #define setflags(ino, data) findblock((unsigned long)(ino), setFlags, data) ! 166: #define orflags(ino, data) findblock((unsigned long)(ino), orFlags, data) ! 167: ! 168: #define linkctr(ino) findblock((unsigned long)(ino), linkCtr) ! 169: #define inclinkctr(ino) findblock((unsigned long)(ino), incLinkctr) ! 170: #define setlinkctr(ino, data) findblock((unsigned long)(ino), setLinkctr, data) ! 171: ! 172: #define badblks(ino) (flags(ino)&IBAD_IDUP) ! 173: ! 174: #else ! 175: unsigned short *linkPtr; ! 176: unsigned char *flagPtr, *blockPtr, *dupPtr; ! 177: ! 178: #define bix(bn) (((unsigned long)(bn)) >> LOGNBPC) ! 179: #define bitm(bn) (1 << ((bn) & (NBPC - 1))) ! 180: ! 181: #define testblock(bn) (blockPtr[bix(bn)] & bitm(bn)) ! 182: #define markblock(bn) (blockPtr[bix(bn)] |= bitm(bn)) ! 183: #define unmarkblock(bn) (blockPtr[bix(bn)] ^= bitm(bn)) ! 184: ! 185: #define testdup(bn) (dupPtr[bix(bn)] & bitm(bn)) ! 186: #define markdup(bn) (dupPtr[bix(bn)] |= bitm(bn)) ! 187: #define unmarkdup(bn) (dupPtr[bix(bn)] ^= bitm(bn)) ! 188: ! 189: #define flags(ino) flagPtr[ino - 1] ! 190: #define setflags(ino, data) (flags(ino) = data) ! 191: #define orflags(ino, data) (flags(ino) |= data) ! 192: ! 193: #define linkctr(ino) linkPtr[ino - 1] ! 194: #define inclinkctr(ino) (++linkctr(ino)) ! 195: #define setlinkctr(ino, data) (linkctr(ino) = data) ! 196: ! 197: #define badblks(ino) (flags(ino) & IBAD_IDUP) ! 198: #endif ! 199: ! 200: /* ! 201: * Miscellany ! 202: */ ! 203: #define NBPC 8 /* number of bits per character */ ! 204: #define LOGNBPC 3 /* Log2 Number of Bits per Character */ ! 205: #define MAXINTN 255 /* used for interleave table */ ! 206: /* in phase6.c */ ! 207: /* ! 208: * Stdio Stuff ! 209: */ ! 210: extern char *malloc(); ! 211: extern char *calloc(); ! 212: #undef putchar(c) ! 213: #define putchar(c) { char b = c; write(1, &b, 1); }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.