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();

Defined variables

bflag defined in line 137; used 6 times
blockmap defined in line 142; used 6 times
cgblk defined in line 58; used 5 times
endpathname defined in line 148; used 1 times
fileblk defined in line 56; used 21 times
hotroot defined in line 140; used 7 times
lfname defined in line 154; used 6 times
muldup defined in line 122; used 10 times
nflag defined in line 135; used 4 times
pathname defined in line 146; used 11 times
pathp defined in line 147; used 20 times
rawflg defined in line 133; used 2 times
sblk defined in line 57; used 10 times
yflag defined in line 136; used 3 times
zino defined in line 163; used 3 times
zlnhead defined in line 131; used 10 times

Defined struct's

bufarea defined in line 37; used 4 times
  • in line 38(2), 53(2)
dups defined in line 117; used 24 times
filecntl defined in line 70; used 8 times
inodesc defined in line 78; used 80 times
zlncnt defined in line 127; used 14 times

Defined enum's

fixstate defined in line 76; used 2 times
  • in line 79(2)

Defined typedef's

BUFAREA defined in line 53; used 10 times
DIRECT defined in line 26; used 19 times

Defined macros

ALLOC defined in line 28; used 1 times
ALTERED defined in line 169; used 19 times
BUFSIZ defined in line 15; used 8 times
DATA defined in line 93; used 9 times
DCLEAR defined in line 22; used 3 times
DFOUND defined in line 21; used 5 times
FCLEAR defined in line 23; used 2 times
FSTATE defined in line 19; used 3 times
MAXBAD defined in line 10; used 1 times
MAXDUP defined in line 9; used 1 times
MAXINOPB defined in line 34; used 1 times
  • in line 48
MAXNINDIR defined in line 33; used 1 times
  • in line 45
SPECIAL defined in line 30; used 2 times
SPERB defined in line 35; used 1 times
  • in line 44
USTATE defined in line 18; used 8 times
cgdirty defined in line 64; used 2 times
cgrp defined in line 68; used 17 times
clrbmap defined in line 167; used 1 times
dirblk defined in line 66; used 11 times
dirty defined in line 61; used 7 times
initbarea defined in line 60; used 6 times
sblock defined in line 67; used 182 times
setbmap defined in line 165; used 3 times
zapino defined in line 162; used 4 times

Usage of this include

Last modified: 1985-10-23
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1811
Valid CSS Valid XHTML 1.0 Strict