Annotation of coherent/b/etc/fsck/fsck.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.