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: #define STEPSIZE    7   /* default step for freelist spacing */
  13: #define CYLSIZE     400 /* default cyl size for spacing */
  14: #define MAXCYL      500 /* maximum cylinder size */
  15: 
  16: typedef int (*SIG_TYP)();
  17: 
  18: #ifndef BUFSIZ
  19: #define BUFSIZ 1024
  20: #endif
  21: 
  22: #define USTATE  01      /* inode not allocated */
  23: #define FSTATE  02      /* inode is file */
  24: #define DSTATE  03      /* inode is directory */
  25: #define DFOUND  04      /* directory found during descent */
  26: #define DCLEAR  05      /* directory is to be cleared */
  27: #define FCLEAR  06      /* file is to be cleared */
  28: 
  29: #define BITSPB  8       /* number bits per byte */
  30: #define BITSHIFT    3   /* log2(BITSPB) */
  31: #define BITMASK 07      /* BITSPB-1 */
  32: #define LSTATE  4       /* bits per inode state */
  33: #define STATEPB (BITSPB/LSTATE) /* inode states per byte */
  34: #define SMASK   017     /* mask for inode state */
  35: 
  36: typedef struct dinode   DINODE;
  37: typedef struct direct   DIRECT;
  38: 
  39: #define ALLOC(dip)  (((dip)->di_mode & IFMT) != 0)
  40: #define DIRCT(dip)  (((dip)->di_mode & IFMT) == IFDIR)
  41: #define SPECIAL(dip) \
  42:     (((dip)->di_mode & IFMT) == IFBLK || ((dip)->di_mode & IFMT) == IFCHR)
  43: 
  44: #define MAXNINDIR   (MAXBSIZE / sizeof (daddr_t))
  45: #define MAXINOPB    (MAXBSIZE / sizeof (struct dinode))
  46: #define SPERB       (MAXBSIZE / sizeof(short))
  47: 
  48: struct bufarea {
  49:     struct bufarea  *b_next;        /* must be first */
  50:     daddr_t b_bno;
  51:     int b_size;
  52:     int b_errs;
  53:     union {
  54:         char    b_buf[MAXBSIZE];    /* buffer space */
  55:         short   b_lnks[SPERB];      /* link counts */
  56:         daddr_t b_indir[MAXNINDIR]; /* indirect block */
  57:         struct  fs b_fs;        /* super block */
  58:         struct  fblk b_fb;      /* free block */
  59:         struct dinode b_dinode[MAXINOPB]; /* inode block */
  60:     } b_un;
  61:     char    b_dirty;
  62: };
  63: 
  64: typedef struct bufarea BUFAREA;
  65: 
  66: BUFAREA inoblk;         /* inode blocks */
  67: BUFAREA fileblk;        /* other blks in filesys */
  68: BUFAREA sblk;           /* file system superblock */
  69: BUFAREA *poolhead;      /* ptr to first buffer in pool */
  70: 
  71: #define initbarea(x)    (x)->b_dirty = 0;(x)->b_bno = (daddr_t)-1
  72: #define dirty(x)    (x)->b_dirty = 1
  73: #define inodirty()  inoblk.b_dirty = 1
  74: #define fbdirty()   fileblk.b_dirty = 1
  75: #define sbdirty()   sblk.b_dirty = 1
  76: 
  77: #define dirblk      fileblk.b_un
  78: #define freeblk     fileblk.b_un.b_fb
  79: #define sblock      sblk.b_un.b_fs
  80: 
  81: struct filecntl {
  82:     int rfdes;
  83:     int wfdes;
  84:     int mod;
  85: } dfile, sfile;         /* file descriptors for filesys/scratch files */
  86: 
  87: enum fixstate {DONTKNOW, NOFIX, FIX};
  88: 
  89: struct inodesc {
  90:     enum fixstate id_fix;   /* policy on fixing errors */
  91:     int (*id_func)();   /* function to be applied to blocks of inode */
  92:     ino_t id_number;    /* inode number described */
  93:     ino_t id_parent;    /* for DATA nodes, their parent */
  94:     daddr_t id_blkno;   /* current block number being examined */
  95:     long id_filesize;   /* for DATA nodes, the size of the directory */
  96:     off_t id_loc;       /* for DATA nodes, current location in dir */
  97:     u_long id_entryno;  /* for DATA nodes, current entry number */
  98:     DIRECT *id_dirp;    /* for DATA nodes, ptr to current entry */
  99:     char *id_name;      /* for DATA nodes, name to find or enter */
 100:     char id_type;       /* type of descriptor, DATA or ADDR */
 101: };
 102: /* file types */
 103: #define DATA    1
 104: #define ADDR    2
 105: 
 106: /*
 107:  * Linked list of duplicate blocks.
 108:  *
 109:  * The list is composed of two parts. The first part of the
 110:  * list (from duplist through the node pointed to by muldup)
 111:  * contains a single copy of each duplicate block that has been
 112:  * found. The second part of the list (from muldup to the end)
 113:  * contains duplicate blocks that have been found more than once.
 114:  * To check if a block has been found as a duplicate it is only
 115:  * necessary to search from duplist through muldup. To find the
 116:  * total number of times that a block has been found as a duplicate
 117:  * the entire list must be searched for occurences of the block
 118:  * in question. The following diagram shows a sample list where
 119:  * w (found twice), x (found once), y (found three times), and z
 120:  * (found once) are duplicate block numbers:
 121:  *
 122:  *    w -> y -> x -> z -> y -> w -> y
 123:  *    ^		     ^
 124:  *    |		     |
 125:  * duplist	  muldup
 126:  */
 127: 
 128: #define DUPTBLSIZE  100
 129: 
 130: daddr_t duplist[DUPTBLSIZE];    /* head of dup list */
 131: daddr_t *enddup;            /* next entry in dup table */
 132: daddr_t *muldup;        /* multiple dups part of table */
 133: 
 134: /*
 135:  * List of inodes with zero link counts.
 136:  */
 137: 
 138: #define MAXLNCNT    50
 139: 
 140: ino_t   zlnlist[MAXLNCNT];  /* zero link count table */
 141: ino_t   *zlnp;
 142: 
 143: #define MAXDATA ((unsigned)56 * 1024)
 144: #define MEMUNIT 64
 145: #define NINOBLK 4       /* number of blocks of inodes to read at once */
 146: 
 147: char    inobuf[NINOBLK*INOPB*sizeof (struct dinode)];   /* allocate now */
 148: daddr_t startib;
 149: 
 150: unsigned int memsize;
 151: char    rawflg;
 152: char    *devname;
 153: char    nflag;          /* assume a no response */
 154: char    yflag;          /* assume a yes response */
 155: char    sflag;          /* rebuild free list */
 156: int debug;          /* output debugging info */
 157: char    preen;          /* just fix normal inconsistencies */
 158: char    hotroot;        /* checking root device */
 159: char    fixfree;        /* force rebuild of freelist */
 160: char    *membase;       /* base of memory we get */
 161: 
 162: char    *blockmap;      /* ptr to primary blk allocation map */
 163: char    *freemap;       /* ptr to secondary blk allocation map */
 164: char    *statemap;      /* ptr to inode state table */
 165: short   *lncntp;        /* ptr to link count table */
 166: 
 167: char    pathname[MAXPATHLEN];   /* current pathname */
 168: char    scrfile[80];        /* scratchfile name */
 169: int cylsize;        /* num blocks per cylinder */
 170: int stepsize;       /* num blocks for spacing purposes */
 171: char    *pathp;         /* pointer to pathname position */
 172: char    *endpathname;
 173: 
 174: daddr_t fmin;           /* block number of the first data block */
 175: daddr_t fmax;           /* number of blocks in the volume */
 176: ino_t   imax;           /* number of inodes */
 177: ino_t   lastino;        /* hiwater mark of inodes */
 178: ino_t   lfdir;          /* lost & found directory inode number */
 179: char    *lfname;        /* lost & found directory name */
 180: 
 181: off_t   bmapsz;         /* num chars in blockmap */
 182: daddr_t bmapblk;        /* starting blk of block map */
 183: daddr_t smapblk;        /* starting blk of state map */
 184: daddr_t lncntblk;       /* starting blk of link cnt table */
 185: daddr_t fmapblk;        /* starting blk of free map */
 186: 
 187: daddr_t n_blks;         /* number of blocks used */
 188: daddr_t n_files;        /* number of files seen */
 189: daddr_t n_free;         /* number of free blocks */
 190: int badblk, dupblk;
 191: 
 192: #define outrange(x) (x < fmin || x >= fmax)
 193: #define zapino(x)   (*(x) = zino)
 194: struct  dinode  zino;
 195: 
 196: #define setlncnt(x,n)   dolncnt(x,0,n)
 197: #define getlncnt(x) dolncnt(x,1,0)
 198: #define declncnt(x) dolncnt(x,2,0)
 199: #define inclncnt(x) dolncnt(x,3,0)
 200: 
 201: #define setbmap(x)  domap(x,0)
 202: #define getbmap(x)  domap(x,1)
 203: #define clrbmap(x)  domap(x,2)
 204: 
 205: #define setfmap(x)  domap(x,0+4)
 206: #define getfmap(x)  domap(x,1+4)
 207: #define clrfmap(x)  domap(x,2+4)
 208: 
 209: #define setstate(x,y)   dostate(x,y,0)
 210: #define getstate(x) dostate(x,0,1)
 211: 
 212: #define ALTERED 010
 213: #define KEEPON  04
 214: #define SKIP    02
 215: #define STOP    01
 216: 
 217: time_t  time();
 218: DINODE  *ginode();
 219: BUFAREA *getblk();
 220: int findino();
 221: daddr_t allocblk();

Defined variables

badblk defined in line 190; used 6 times
cylsize defined in line 169; used 9 times
dupblk defined in line 190; used 6 times
endpathname defined in line 172; used 1 times
fileblk defined in line 67; used 27 times
fixfree defined in line 159; used 9 times
hotroot defined in line 158; used 8 times
inobuf defined in line 147; used 4 times
lfname defined in line 179; used 6 times
lncntp defined in line 165; used 7 times
membase defined in line 160; used 2 times
memsize defined in line 150; used 8 times
pathname defined in line 167; used 11 times
pathp defined in line 171; used 20 times
poolhead defined in line 69; used 8 times
rawflg defined in line 151; used 2 times
sblk defined in line 68; used 9 times
scrfile defined in line 168; used 5 times
sfile defined in line 85; used 10 times
sflag defined in line 155; used 2 times
statemap defined in line 164; used 6 times
stepsize defined in line 170; used 8 times
yflag defined in line 154; used 3 times
zino defined in line 194; used 3 times

Defined struct's

bufarea defined in line 48; used 4 times
  • in line 49(2), 64(2)
filecntl defined in line 81; used 8 times
inodesc defined in line 89; used 78 times

Defined enum's

fixstate defined in line 87; used 2 times
  • in line 90(2)

Defined typedef's

BUFAREA defined in line 64; used 27 times
DIRECT defined in line 37; used 19 times

Defined macros

ALLOC defined in line 39; used 1 times
ALTERED defined in line 212; used 19 times
BITMASK defined in line 31; used 1 times
BITSHIFT defined in line 30; used 1 times
BITSPB defined in line 29; used 2 times
BUFSIZ defined in line 19; used 1 times
  • in line 18
CYLSIZE defined in line 13; used 1 times
DATA defined in line 103; used 9 times
DCLEAR defined in line 26; used 3 times
DUPTBLSIZE defined in line 128; used 3 times
FCLEAR defined in line 27; used 2 times
LSTATE defined in line 32; used 2 times
MAXBAD defined in line 10; used 2 times
MAXCYL defined in line 14; used 4 times
MAXDATA defined in line 143; used 1 times
MAXDUP defined in line 9; used 1 times
MAXINOPB defined in line 45; used 1 times
  • in line 59
MAXLNCNT defined in line 138; used 2 times
MAXNINDIR defined in line 44; used 1 times
  • in line 56
MEMUNIT defined in line 144; used 1 times
NINOBLK defined in line 145; used 5 times
SMASK defined in line 34; used 2 times
SPECIAL defined in line 41; used 2 times
SPERB defined in line 46; used 3 times
STATEPB defined in line 33; used 3 times
STEPSIZE defined in line 12; used 1 times
clrbmap defined in line 203; used 1 times
clrfmap defined in line 207; never used
declncnt defined in line 198; used 5 times
dirblk defined in line 77; used 11 times
fbdirty defined in line 74; used 1 times
freeblk defined in line 78; used 17 times
getfmap defined in line 206; used 1 times
getlncnt defined in line 197; used 2 times
inclncnt defined in line 199; used 2 times
initbarea defined in line 71; used 5 times
sblock defined in line 79; used 39 times
setbmap defined in line 201; used 3 times
setfmap defined in line 205; used 1 times
setlncnt defined in line 196; used 4 times
setstate defined in line 209; used 18 times
zapino defined in line 193; used 5 times

Usage of this include

Last modified: 1990-04-26
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4222
Valid CSS Valid XHTML 1.0 Strict