Annotation of researchv9/sys/h/inode.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * The I node is the focus of all
        !             3:  * file activity in unix. There is a unique
        !             4:  * inode allocated for each active file,
        !             5:  * each current directory, each mounted-on
        !             6:  * file, text file, and the root. An inode is 'named'
        !             7:  * by its dev/inumber pair. (iget/iget.c)
        !             8:  * Data, from mode on, is read in
        !             9:  * from permanent inode on volume.
        !            10:  */
        !            11: 
        !            12: #define        NADDR   13
        !            13: 
        !            14: struct inode
        !            15: {
        !            16:        short   i_flag;
        !            17:        u_char  i_count;        /* reference count */
        !            18:        char    i_fstyp;        /* type of its filesystem */
        !            19:        dev_t   i_dev;          /* device where inode resides */
        !            20:        long    i_number;       /* i number, 1-to-1 with device address */
        !            21:        unsigned short i_mode;
        !            22:        short   i_nlink;        /* directory entries */
        !            23:        short   i_uid;          /* owner */
        !            24:        short   i_gid;          /* group of owner */
        !            25:        off_t   i_size;         /* size of file */
        !            26:        struct  inode *i_mroot; /* if mount point, root inode */
        !            27:        struct  inode *i_mpoint;        /* inode of mount point */
        !            28:        struct  stdata *i_sptr; /* stream associated with this inode */
        !            29:        union {
        !            30:                struct {
        !            31:                        daddr_t I_addr[NADDR];  /* if normal file/directory */
        !            32:                        daddr_t I_lastr;        /* last read (for read-ahead) */
        !            33:                        struct buf *I_bufp;     /* buffer for super-block */
        !            34:                } i_f;
        !            35: #define        i_addr  i_f.I_addr
        !            36: #define        i_lastr i_f.I_lastr
        !            37: #define        i_bufp  i_f.I_bufp
        !            38:                struct {
        !            39:                        daddr_t I_rdev;         /* i_addr[0] */
        !            40:                        long    I_key;          /* see istread */
        !            41:                } i_d;
        !            42: #define        i_rdev  i_d.I_rdev
        !            43: #define i_key  i_d.I_key
        !            44:                struct {
        !            45:                        long I_tag;
        !            46:                        struct inode *I_cip;    /* communications */
        !            47:                } i_a;          /* when i_fstyp != 0 */
        !            48: #define i_tag  i_a.I_tag
        !            49: #define i_cip  i_a.I_cip
        !            50:                struct {
        !            51:                        struct proc *I_proc;    /* sanity checking */
        !            52:                        int         I_sigmask;  /* signal trace mask */
        !            53:                } i_p;
        !            54: #define i_proc i_p.I_proc
        !            55: #define i_sigmask      i_p.I_sigmask
        !            56:        } i_un;
        !            57:        struct inode *i_hlink;  /* link in hash chain (iget/iput/ifind) */
        !            58: };
        !            59: 
        !            60: #ifdef KERNEL
        !            61: struct inode *inode, *inodeNINODE;
        !            62: int    ninode;
        !            63: 
        !            64: struct inode *rootdir;         /* pointer to inode of root directory */
        !            65: 
        !            66: struct inode *ialloc();
        !            67: struct inode *ifind();
        !            68: struct inode *iget();
        !            69: struct inode *owner();
        !            70: struct inode *maknode();
        !            71: struct inode *namei();
        !            72: struct inode *openi();
        !            73: #endif
        !            74: 
        !            75: /* flags */
        !            76: #define        ILOCK   01              /* inode is locked */
        !            77: #define        IUPD    02              /* file has been modified */
        !            78: #define        IACC    04              /* inode access time to be updated */
        !            79: #define        IMOUNT  010             /* inode is mounted on */
        !            80: #define        IWANT   020             /* some process waiting on lock */
        !            81: #define        ITEXT   040             /* inode is pure text prototype */
        !            82: #define        ICHG    0100            /* inode has been changed */
        !            83: #define        IPIPE   0200            /* inode is a pipe */
        !            84: #define IDEAD  0400            /* only iput and iget */
        !            85: 
        !            86: /* modes */
        !            87: #define        IFMT    0170000         /* type of file */
        !            88: #define                IFDIR   0040000 /* directory */
        !            89: #define                IFCHR   0020000 /* character special */
        !            90: #define                IFBLK   0060000 /* block special */
        !            91: #define                IFREG   0100000 /* regular */
        !            92: #define                IFLNK   0120000 /* symbolic link to another file */
        !            93: #define        ISUID   04000           /* set user id on execution */
        !            94: #define        ISGID   02000           /* set group id on execution */
        !            95: #define        IREAD   0400            /* read, write, execute permissions */
        !            96: #define        IWRITE  0200
        !            97: #define        IEXEC   0100
        !            98: #define        ICONC   0001000         /* this file is protected for concurrent access */
        !            99: #define        ICCTYP  0007000         /* type of concurrent access */
        !           100: #define                ISYNC   0001000 /* 1 writer and n readers (synchronized access) */
        !           101: #define                IEXCL   0003000 /* 1 writer or n readers (exclusive access) */
        !           102: 
        !           103: struct argnamei {      /* namei's flag argument */
        !           104:        short flag;     /* type of request */
        !           105:        short mode;     /* mode for creating */
        !           106:        struct inode *il;       /* for linking */
        !           107:        short done;     /* used as a return flag in creat */
        !           108: } nilargnamei;
        !           109: #define NI_DEL 1       /* unlink this file */
        !           110: #define NI_CREAT 2     /* create it if it doesn't exits */
        !           111: #define NI_NXCREAT 3   /* create it, error if it already exists */
        !           112: #define NI_LINK        4       /* make a link */
        !           113: #define NI_MKDIR 5     /* make a directory */
        !           114: #define NI_RMDIR 6     /* remove a directory */
        !           115: struct nx {    /* arg to real nami */
        !           116:        struct inode *dp;
        !           117:        char *cp;
        !           118:        struct buf *nbp;
        !           119:        int nlink;
        !           120: };
        !           121: 
        !           122: /*
        !           123:  * some inline subroutines to speed things up
        !           124:  */
        !           125: 
        !           126: #ifdef KERNEL
        !           127: 
        !           128: #define        plock(ip) \
        !           129: { \
        !           130:        while ((ip)->i_flag & ILOCK) { \
        !           131:                (ip)->i_flag |= IWANT; \
        !           132:                sleep((caddr_t)(ip), PINOD); \
        !           133:        } \
        !           134:        (ip)->i_flag |= ILOCK; \
        !           135: }
        !           136: 
        !           137: #define        prele(ip) \
        !           138: { \
        !           139:        (ip)->i_flag &= ~ILOCK; \
        !           140:        if ((ip)->i_flag&IWANT) { \
        !           141:                (ip)->i_flag &= ~IWANT; \
        !           142:                wakeup((caddr_t)(ip)); \
        !           143:        } \
        !           144: }
        !           145: 
        !           146: #endif

unix.superglobalmegacorp.com

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