Annotation of 43BSDReno/sbin/fsck/fsck.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980, 1986 The Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted provided
        !             6:  * that: (1) source distributions retain this entire copyright notice and
        !             7:  * comment, and (2) distributions including binaries display the following
        !             8:  * acknowledgement:  ``This product includes software developed by the
        !             9:  * University of California, Berkeley and its contributors'' in the
        !            10:  * documentation or other materials provided with the distribution and in
        !            11:  * all advertising materials mentioning features or use of this software.
        !            12:  * Neither the name of the University nor the names of its contributors may
        !            13:  * be used to endorse or promote products derived from this software without
        !            14:  * specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
        !            16:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
        !            17:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  *
        !            19:  *     @(#)fsck.h      5.17 (Berkeley) 7/27/90
        !            20:  */
        !            21: 
        !            22: #define        MAXDUP          10      /* limit on dup blks (per inode) */
        !            23: #define        MAXBAD          10      /* limit on bad blks (per inode) */
        !            24: #define        MAXBUFSPACE     40*1024 /* maximum space to allocate to buffers */
        !            25: #define        INOBUFSIZE      56*1024 /* size of buffer to read inodes in pass1 */
        !            26: 
        !            27: #ifndef BUFSIZ
        !            28: #define BUFSIZ 1024
        !            29: #endif
        !            30: 
        !            31: #define        USTATE  01              /* inode not allocated */
        !            32: #define        FSTATE  02              /* inode is file */
        !            33: #define        DSTATE  03              /* inode is directory */
        !            34: #define        DFOUND  04              /* directory found during descent */
        !            35: #define        DCLEAR  05              /* directory is to be cleared */
        !            36: #define        FCLEAR  06              /* file is to be cleared */
        !            37: 
        !            38: /*
        !            39:  * buffer cache structure.
        !            40:  */
        !            41: struct bufarea {
        !            42:        struct bufarea  *b_next;                /* free list queue */
        !            43:        struct bufarea  *b_prev;                /* free list queue */
        !            44:        daddr_t b_bno;
        !            45:        int     b_size;
        !            46:        int     b_errs;
        !            47:        int     b_flags;
        !            48:        union {
        !            49:                char    *b_buf;                 /* buffer space */
        !            50:                daddr_t *b_indir;               /* indirect block */
        !            51:                struct  fs *b_fs;               /* super block */
        !            52:                struct  cg *b_cg;               /* cylinder group */
        !            53:                struct  dinode *b_dinode;       /* inode block */
        !            54:        } b_un;
        !            55:        char    b_dirty;
        !            56: };
        !            57: 
        !            58: #define        B_INUSE 1
        !            59: 
        !            60: #define        MINBUFS         5       /* minimum number of buffers required */
        !            61: struct bufarea bufhead;                /* head of list of other blks in filesys */
        !            62: struct bufarea sblk;           /* file system superblock */
        !            63: struct bufarea cgblk;          /* cylinder group blocks */
        !            64: struct bufarea *pdirbp;                /* current directory contents */
        !            65: struct bufarea *pbp;           /* current inode block */
        !            66: struct bufarea *getdatablk();
        !            67: 
        !            68: #define        dirty(bp)       (bp)->b_dirty = 1
        !            69: #define        initbarea(bp) \
        !            70:        (bp)->b_dirty = 0; \
        !            71:        (bp)->b_bno = (daddr_t)-1; \
        !            72:        (bp)->b_flags = 0;
        !            73: 
        !            74: #define        sbdirty()       sblk.b_dirty = 1
        !            75: #define        cgdirty()       cgblk.b_dirty = 1
        !            76: #define        sblock          (*sblk.b_un.b_fs)
        !            77: #define        cgrp            (*cgblk.b_un.b_cg)
        !            78: 
        !            79: enum fixstate {DONTKNOW, NOFIX, FIX, IGNORE};
        !            80: 
        !            81: struct inodesc {
        !            82:        enum fixstate id_fix;   /* policy on fixing errors */
        !            83:        int (*id_func)();       /* function to be applied to blocks of inode */
        !            84:        ino_t id_number;        /* inode number described */
        !            85:        ino_t id_parent;        /* for DATA nodes, their parent */
        !            86:        daddr_t id_blkno;       /* current block number being examined */
        !            87:        int id_numfrags;        /* number of frags contained in block */
        !            88:        long id_filesize;       /* for DATA nodes, the size of the directory */
        !            89:        int id_loc;             /* for DATA nodes, current location in dir */
        !            90:        int id_entryno;         /* for DATA nodes, current entry number */
        !            91:        struct direct *id_dirp; /* for DATA nodes, ptr to current entry */
        !            92:        char *id_name;          /* for DATA nodes, name to find or enter */
        !            93:        char id_type;           /* type of descriptor, DATA or ADDR */
        !            94: };
        !            95: /* file types */
        !            96: #define        DATA    1
        !            97: #define        ADDR    2
        !            98: 
        !            99: /*
        !           100:  * Linked list of duplicate blocks.
        !           101:  * 
        !           102:  * The list is composed of two parts. The first part of the
        !           103:  * list (from duplist through the node pointed to by muldup)
        !           104:  * contains a single copy of each duplicate block that has been 
        !           105:  * found. The second part of the list (from muldup to the end)
        !           106:  * contains duplicate blocks that have been found more than once.
        !           107:  * To check if a block has been found as a duplicate it is only
        !           108:  * necessary to search from duplist through muldup. To find the 
        !           109:  * total number of times that a block has been found as a duplicate
        !           110:  * the entire list must be searched for occurences of the block
        !           111:  * in question. The following diagram shows a sample list where
        !           112:  * w (found twice), x (found once), y (found three times), and z
        !           113:  * (found once) are duplicate block numbers:
        !           114:  *
        !           115:  *    w -> y -> x -> z -> y -> w -> y
        !           116:  *    ^                     ^
        !           117:  *    |                     |
        !           118:  * duplist       muldup
        !           119:  */
        !           120: struct dups {
        !           121:        struct dups *next;
        !           122:        daddr_t dup;
        !           123: };
        !           124: struct dups *duplist;          /* head of dup list */
        !           125: struct dups *muldup;           /* end of unique duplicate dup block numbers */
        !           126: 
        !           127: /*
        !           128:  * Linked list of inodes with zero link counts.
        !           129:  */
        !           130: struct zlncnt {
        !           131:        struct zlncnt *next;
        !           132:        ino_t zlncnt;
        !           133: };
        !           134: struct zlncnt *zlnhead;                /* head of zero link count list */
        !           135: 
        !           136: /*
        !           137:  * Inode cache data structures.
        !           138:  */
        !           139: struct inoinfo {
        !           140:        struct  inoinfo *i_nexthash;    /* next entry in hash chain */
        !           141:        ino_t   i_number;               /* inode number of this entry */
        !           142:        ino_t   i_parent;               /* inode number of parent */
        !           143:        ino_t   i_dotdot;               /* inode number of `..' */
        !           144:        size_t  i_isize;                /* size of inode */
        !           145:        u_int   i_numblks;              /* size of block array in bytes */
        !           146:        daddr_t i_blks[1];              /* actually longer */
        !           147: } **inphead, **inpsort;
        !           148: long numdirs, listmax, inplast;
        !           149: 
        !           150: char   *devname;               /* name of device being checked */
        !           151: long   dev_bsize;              /* computed value of DEV_BSIZE */
        !           152: long   secsize;                /* actual disk sector size */
        !           153: char   nflag;                  /* assume a no response */
        !           154: char   yflag;                  /* assume a yes response */
        !           155: int    bflag;                  /* location of alternate super block */
        !           156: int    debug;                  /* output debugging info */
        !           157: int    cvtflag;                /* convert to old file system format */
        !           158: char   preen;                  /* just fix normal inconsistencies */
        !           159: char   hotroot;                /* checking root device */
        !           160: char   havesb;                 /* superblock has been read */
        !           161: int    fsmodified;             /* 1 => write done to file system */
        !           162: int    fsreadfd;               /* file descriptor for reading file system */
        !           163: int    fswritefd;              /* file descriptor for writing file system */
        !           164: 
        !           165: daddr_t        maxfsblock;             /* number of blocks in the file system */
        !           166: char   *blockmap;              /* ptr to primary blk allocation map */
        !           167: ino_t  maxino;                 /* number of inodes in file system */
        !           168: ino_t  lastino;                /* last inode in use */
        !           169: char   *statemap;              /* ptr to inode state table */
        !           170: short  *lncntp;                /* ptr to link count table */
        !           171: 
        !           172: ino_t  lfdir;                  /* lost & found directory inode number */
        !           173: char   *lfname;                /* lost & found directory name */
        !           174: int    lfmode;                 /* lost & found directory creation mode */
        !           175: 
        !           176: daddr_t        n_blks;                 /* number of blocks in use */
        !           177: daddr_t        n_files;                /* number of files in use */
        !           178: 
        !           179: #define        clearinode(dp)  (*(dp) = zino)
        !           180: struct dinode zino;
        !           181: 
        !           182: #define        setbmap(blkno)  setbit(blockmap, blkno)
        !           183: #define        testbmap(blkno) isset(blockmap, blkno)
        !           184: #define        clrbmap(blkno)  clrbit(blockmap, blkno)
        !           185: 
        !           186: #define        STOP    0x01
        !           187: #define        SKIP    0x02
        !           188: #define        KEEPON  0x04
        !           189: #define        ALTERED 0x08
        !           190: #define        FOUND   0x10
        !           191: 
        !           192: time_t time();
        !           193: struct dinode *ginode();
        !           194: struct inoinfo *getinoinfo();
        !           195: void getblk();
        !           196: ino_t allocino();
        !           197: int findino();

unix.superglobalmegacorp.com

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