|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1980 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)fsck.h 5.7 (Berkeley) 5/7/88 ! 7: */ ! 8: ! 9: #define MAXDUP 10 /* limit on dup blks (per inode) */ ! 10: #define MAXBAD 10 /* limit on bad blks (per inode) */ ! 11: #define MAXBUFSPACE 128*1024 /* maximum space to allocate to buffers */ ! 12: ! 13: typedef int (*SIG_TYP)(); ! 14: ! 15: #ifndef BUFSIZ ! 16: #define BUFSIZ 1024 ! 17: #endif ! 18: ! 19: #define USTATE 01 /* inode not allocated */ ! 20: #define FSTATE 02 /* inode is file */ ! 21: #define DSTATE 03 /* inode is directory */ ! 22: #define DFOUND 04 /* directory found during descent */ ! 23: #define DCLEAR 05 /* directory is to be cleared */ ! 24: #define FCLEAR 06 /* file is to be cleared */ ! 25: ! 26: typedef struct dinode DINODE; ! 27: typedef struct direct DIRECT; ! 28: ! 29: #define ALLOC(dip) (((dip)->di_mode & IFMT) != 0) ! 30: #define DIRCT(dip) (((dip)->di_mode & IFMT) == IFDIR) ! 31: #define SPECIAL(dip) \ ! 32: (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR) ! 33: ! 34: /* ! 35: * buffer cache structure. ! 36: */ ! 37: struct bufarea { ! 38: struct bufarea *b_next; /* free list queue */ ! 39: struct bufarea *b_prev; /* free list queue */ ! 40: daddr_t b_bno; ! 41: int b_size; ! 42: int b_errs; ! 43: int b_flags; ! 44: union { ! 45: char *b_buf; /* buffer space */ ! 46: daddr_t *b_indir; /* indirect block */ ! 47: struct fs *b_fs; /* super block */ ! 48: struct cg *b_cg; /* cylinder group */ ! 49: struct dinode *b_dinode; /* inode block */ ! 50: } b_un; ! 51: char b_dirty; ! 52: }; ! 53: ! 54: #define B_INUSE 1 ! 55: typedef struct bufarea BUFAREA; ! 56: ! 57: #define MINBUFS 5 /* minimum number of buffers required */ ! 58: BUFAREA bufhead; /* head of list of other blks in filesys */ ! 59: BUFAREA sblk; /* file system superblock */ ! 60: BUFAREA cgblk; /* cylinder group blocks */ ! 61: BUFAREA *getdatablk(); ! 62: ! 63: #define dirty(x) (x)->b_dirty = 1 ! 64: #define initbarea(x) \ ! 65: (x)->b_dirty = 0; \ ! 66: (x)->b_bno = (daddr_t)-1; \ ! 67: (x)->b_flags = 0; ! 68: ! 69: #define sbdirty() sblk.b_dirty = 1 ! 70: #define cgdirty() cgblk.b_dirty = 1 ! 71: #define sblock (*sblk.b_un.b_fs) ! 72: #define cgrp (*cgblk.b_un.b_cg) ! 73: ! 74: struct filecntl { ! 75: int rfdes; ! 76: int wfdes; ! 77: int mod; ! 78: } dfile; /* file descriptors for filesys */ ! 79: ! 80: enum fixstate {DONTKNOW, NOFIX, FIX}; ! 81: ! 82: struct inodesc { ! 83: enum fixstate id_fix; /* policy on fixing errors */ ! 84: int (*id_func)(); /* function to be applied to blocks of inode */ ! 85: ino_t id_number; /* inode number described */ ! 86: ino_t id_parent; /* for DATA nodes, their parent */ ! 87: daddr_t id_blkno; /* current block number being examined */ ! 88: int id_numfrags; /* number of frags contained in block */ ! 89: long id_filesize; /* for DATA nodes, the size of the directory */ ! 90: int id_loc; /* for DATA nodes, current location in dir */ ! 91: int id_entryno; /* for DATA nodes, current entry number */ ! 92: DIRECT *id_dirp; /* for DATA nodes, ptr to current entry */ ! 93: char *id_name; /* for DATA nodes, name to find or enter */ ! 94: char id_type; /* type of descriptor, DATA or ADDR */ ! 95: }; ! 96: /* file types */ ! 97: #define DATA 1 ! 98: #define ADDR 2 ! 99: ! 100: /* ! 101: * Linked list of duplicate blocks. ! 102: * ! 103: * The list is composed of two parts. The first part of the ! 104: * list (from duplist through the node pointed to by muldup) ! 105: * contains a single copy of each duplicate block that has been ! 106: * found. The second part of the list (from muldup to the end) ! 107: * contains duplicate blocks that have been found more than once. ! 108: * To check if a block has been found as a duplicate it is only ! 109: * necessary to search from duplist through muldup. To find the ! 110: * total number of times that a block has been found as a duplicate ! 111: * the entire list must be searched for occurences of the block ! 112: * in question. The following diagram shows a sample list where ! 113: * w (found twice), x (found once), y (found three times), and z ! 114: * (found once) are duplicate block numbers: ! 115: * ! 116: * w -> y -> x -> z -> y -> w -> y ! 117: * ^ ^ ! 118: * | | ! 119: * duplist muldup ! 120: */ ! 121: struct dups { ! 122: struct dups *next; ! 123: daddr_t dup; ! 124: }; ! 125: struct dups *duplist; /* head of dup list */ ! 126: struct dups *muldup; /* end of unique duplicate dup block numbers */ ! 127: ! 128: /* ! 129: * Linked list of inodes with zero link counts. ! 130: */ ! 131: struct zlncnt { ! 132: struct zlncnt *next; ! 133: ino_t zlncnt; ! 134: }; ! 135: struct zlncnt *zlnhead; /* head of zero link count list */ ! 136: ! 137: char rawflg; ! 138: char *devname; ! 139: long dev_bsize; /* computed value of DEV_BSIZE */ ! 140: long secsize; /* actual disk sector size */ ! 141: char nflag; /* assume a no response */ ! 142: char yflag; /* assume a yes response */ ! 143: int bflag; /* location of alternate super block */ ! 144: int debug; /* output debugging info */ ! 145: int cvtflag; /* convert to old file system format */ ! 146: char preen; /* just fix normal inconsistencies */ ! 147: char hotroot; /* checking root device */ ! 148: char havesb; /* superblock has been read */ ! 149: ! 150: char *blockmap; /* ptr to primary blk allocation map */ ! 151: char *statemap; /* ptr to inode state table */ ! 152: short *lncntp; /* ptr to link count table */ ! 153: ! 154: char pathname[BUFSIZ]; /* current pathname */ ! 155: char *pathp; /* pointer to pathname position */ ! 156: char *endpathname; ! 157: ! 158: daddr_t fmax; /* number of blocks in the volume */ ! 159: ino_t imax; /* number of inodes */ ! 160: ino_t lastino; /* hiwater mark of inodes */ ! 161: ino_t lfdir; /* lost & found directory inode number */ ! 162: char *lfname; /* lost & found directory name */ ! 163: ! 164: off_t maxblk; /* largest logical blk in file */ ! 165: off_t bmapsz; /* num chars in blockmap */ ! 166: ! 167: daddr_t n_blks; /* number of blocks used */ ! 168: daddr_t n_files; /* number of files seen */ ! 169: ! 170: #define zapino(x) (*(x) = zino) ! 171: struct dinode zino; ! 172: ! 173: #define setbmap(x) setbit(blockmap, x) ! 174: #define getbmap(x) isset(blockmap, x) ! 175: #define clrbmap(x) clrbit(blockmap, x) ! 176: ! 177: #define FOUND 020 ! 178: #define ALTERED 010 ! 179: #define KEEPON 04 ! 180: #define SKIP 02 ! 181: #define STOP 01 ! 182: ! 183: time_t time(); ! 184: DINODE *ginode(); ! 185: BUFAREA *getblk(); ! 186: int findino();
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.