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