|
|
1.1 ! root 1: /* inode.h 6.1 83/07/29 */ ! 2: /* Documentation Block and Change history : ! 3: bernie 1/28/85 Add define for AUDITLOG. ! 4: ! 5: /* ! 6: * The I node is the focus of all file activity in UNIX. ! 7: * There is a unique inode allocated for each active file, ! 8: * each current directory, each mounted-on file, text file, and the root. ! 9: * An inode is 'named' by its dev/inumber pair. (iget/iget.c) ! 10: * Data in icommon is read in from permanent inode on volume. ! 11: */ ! 12: ! 13: #define NDADDR 12 /* direct addresses in inode */ ! 14: #define NIADDR 3 /* indirect addresses in inode */ ! 15: ! 16: struct inode { ! 17: struct inode *i_chain[2]; /* must be first */ ! 18: u_short i_flag; ! 19: u_short i_count; /* reference count */ ! 20: dev_t i_dev; /* device where inode resides */ ! 21: u_short i_shlockc; /* count of shared locks on inode */ ! 22: u_short i_exlockc; /* count of exclusive locks on inode */ ! 23: ino_t i_number; /* i number, 1-to-1 with device address */ ! 24: struct fs *i_fs; /* file sys associated with this inode */ ! 25: struct dquot *i_dquot; /* quota structure controlling this file */ ! 26: union { ! 27: daddr_t if_lastr; /* last read (read-ahead) */ ! 28: struct socket *is_socket; ! 29: struct { ! 30: struct inode *if_freef; /* free list forward */ ! 31: struct inode **if_freeb; /* free list back */ ! 32: } i_fr; ! 33: } i_un; ! 34: struct icommon ! 35: { ! 36: u_short ic_mode; /* 0: mode and type of file */ ! 37: short ic_nlink; /* 2: number of links to file */ ! 38: short ic_uid; /* 4: owner's user id */ ! 39: short ic_gid; /* 6: owner's group id */ ! 40: quad ic_size; /* 8: number of bytes in file */ ! 41: time_t ic_atime; /* 16: time last accessed */ ! 42: long ic_atspare; ! 43: time_t ic_mtime; /* 24: time last modified */ ! 44: long ic_mtspare; ! 45: time_t ic_ctime; /* 32: last time inode changed */ ! 46: long ic_ctspare; ! 47: daddr_t ic_db[NDADDR]; /* 40: disk block addresses */ ! 48: daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */ ! 49: long ic_flags; /* 100: status, currently unused */ ! 50: long ic_blocks; /* 104: blocks actually held */ ! 51: long ic_spare[5]; /* 108: reserved, currently unused */ ! 52: } i_ic; ! 53: }; ! 54: ! 55: struct dinode { ! 56: union { ! 57: struct icommon di_icom; ! 58: char di_size[128]; ! 59: } di_un; ! 60: }; ! 61: ! 62: #define i_mode i_ic.ic_mode ! 63: #define i_nlink i_ic.ic_nlink ! 64: #define i_uid i_ic.ic_uid ! 65: #define i_gid i_ic.ic_gid ! 66: /* ugh! -- must be fixed */ ! 67: ! 68: #define i_size i_ic.ic_size.val[0] ! 69: ! 70: #define i_db i_ic.ic_db ! 71: #define i_ib i_ic.ic_ib ! 72: #define i_atime i_ic.ic_atime ! 73: #define i_mtime i_ic.ic_mtime ! 74: #define i_ctime i_ic.ic_ctime ! 75: #define i_blocks i_ic.ic_blocks ! 76: #define i_rdev i_ic.ic_db[0] ! 77: #define i_lastr i_un.if_lastr ! 78: #define i_socket i_un.is_socket ! 79: #define i_forw i_chain[0] ! 80: #define i_back i_chain[1] ! 81: #define i_freef i_un.i_fr.if_freef ! 82: #define i_freeb i_un.i_fr.if_freeb ! 83: ! 84: #define di_ic di_un.di_icom ! 85: #define di_mode di_ic.ic_mode ! 86: #define di_nlink di_ic.ic_nlink ! 87: #define di_uid di_ic.ic_uid ! 88: #define di_gid di_ic.ic_gid ! 89: ! 90: #define di_size di_ic.ic_size.val[0] ! 91: ! 92: #define di_db di_ic.ic_db ! 93: #define di_ib di_ic.ic_ib ! 94: #define di_atime di_ic.ic_atime ! 95: #define di_mtime di_ic.ic_mtime ! 96: #define di_ctime di_ic.ic_ctime ! 97: #define di_rdev di_ic.ic_db[0] ! 98: #define di_blocks di_ic.ic_blocks ! 99: ! 100: #ifdef KERNEL ! 101: struct inode *inode; /* the inode table itself */ ! 102: struct inode *inodeNINODE; /* the end of the inode table */ ! 103: int ninode; /* number of slots in the table */ ! 104: ! 105: struct inode *rootdir; /* pointer to inode of root directory */ ! 106: ! 107: struct inode *ialloc(); ! 108: struct inode *iget(); ! 109: #ifdef notdef ! 110: struct inode *ifind(); ! 111: #endif ! 112: struct inode *owner(); ! 113: struct inode *maknode(); ! 114: struct inode *namei(); ! 115: ! 116: ino_t dirpref(); ! 117: #endif ! 118: ! 119: /* flags */ ! 120: #define ILOCKED 0x1 /* inode is locked */ ! 121: #define IUPD 0x2 /* file has been modified */ ! 122: #define IACC 0x4 /* inode access time to be updated */ ! 123: #define IMOUNT 0x8 /* inode is mounted on */ ! 124: #define IWANT 0x10 /* some process waiting on lock */ ! 125: #define ITEXT 0x20 /* inode is pure text prototype */ ! 126: #define ICHG 0x40 /* inode has been changed */ ! 127: #define ISHLOCK 0x80 /* file has shared lock */ ! 128: #define IEXLOCK 0x100 /* file has exclusive lock */ ! 129: #define ILWAIT 0x200 /* someone waiting on file lock */ ! 130: ! 131: /* modes */ ! 132: #define IFMT 0170000 /* type of file */ ! 133: #define IFCHR 0020000 /* character special */ ! 134: #define IFDIR 0040000 /* directory */ ! 135: #define IFBLK 0060000 /* block special */ ! 136: #define IFREG 0100000 /* regular */ ! 137: #define IFLNK 0120000 /* symbolic link */ ! 138: #define IFSOCK 0140000 /* socket */ ! 139: ! 140: #define ISUID 04000 /* set user id on execution */ ! 141: #define ISGID 02000 /* set group id on execution */ ! 142: #define ISVTX 01000 /* save swapped text even after use */ ! 143: #define IREAD 0400 /* read, write, execute permissions */ ! 144: #define IWRITE 0200 ! 145: #define IEXEC 0100 ! 146: /* ic_flags */ ! 147: #define AUDLOG 0x01 /* audit trail logging bit */ ! 148: ! 149: #define ILOCK(ip) { \ ! 150: while ((ip)->i_flag & ILOCKED) { \ ! 151: (ip)->i_flag |= IWANT; \ ! 152: sleep((caddr_t)(ip), PINOD); \ ! 153: } \ ! 154: (ip)->i_flag |= ILOCKED; \ ! 155: } ! 156: ! 157: #define IUNLOCK(ip) { \ ! 158: (ip)->i_flag &= ~ILOCKED; \ ! 159: if ((ip)->i_flag&IWANT) { \ ! 160: (ip)->i_flag &= ~IWANT; \ ! 161: wakeup((caddr_t)(ip)); \ ! 162: } \ ! 163: } ! 164: ! 165: #define IUPDAT(ip, t1, t2, waitfor) { \ ! 166: if (ip->i_flag&(IUPD|IACC|ICHG)) \ ! 167: iupdat(ip, t1, t2, waitfor); \ ! 168: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.