| 1 | /* dinode.h 4.5 81/03/09 */ |
| 2 | |
| 3 | /* |
| 4 | * The I node is the focus of all |
| 5 | * file activity in unix. There is a unique |
| 6 | * inode allocated for each active file, |
| 7 | * each current directory, each mounted-on |
| 8 | * file, text file, and the root. An inode is 'named' |
| 9 | * by its dev/inumber pair. (iget/iget.c) |
| 10 | * Data, from mode on, is read in |
| 11 | * from permanent inode on volume. |
| 12 | */ |
| 13 | |
| 14 | #define NADDR 13 |
| 15 | |
| 16 | #define NINDEX 6 |
| 17 | struct group |
| 18 | { |
| 19 | short g_state; |
| 20 | char g_index; |
| 21 | char g_rot; |
| 22 | struct group *g_group; |
| 23 | struct inode *g_inode; |
| 24 | struct file *g_file; |
| 25 | short g_rotmask; |
| 26 | short g_datq; |
| 27 | struct chan *g_chans[NINDEX]; |
| 28 | }; |
| 29 | struct inode |
| 30 | { |
| 31 | char i_flag; |
| 32 | char i_count; /* reference count */ |
| 33 | dev_t i_dev; /* device where inode resides */ |
| 34 | ino_t i_number; /* i number, 1-to-1 with device address */ |
| 35 | unsigned short i_mode; |
| 36 | short i_nlink; /* directory entries */ |
| 37 | short i_uid; /* owner */ |
| 38 | short i_gid; /* group of owner */ |
| 39 | off_t i_size; /* size of file */ |
| 40 | union { |
| 41 | struct { |
| 42 | daddr_t I_addr[NADDR]; /* if normal file/directory */ |
| 43 | daddr_t I_lastr; /* last read (for read-ahead) */ |
| 44 | } i_f; |
| 45 | #define i_addr i_f.I_addr |
| 46 | #define i_lastr i_f.I_lastr |
| 47 | struct { |
| 48 | daddr_t I_rdev; /* i_addr[0] */ |
| 49 | struct group I_group; /* multiplexor group file */ |
| 50 | } i_d; |
| 51 | #define i_rdev i_d.I_rdev |
| 52 | #define i_group i_d.I_group |
| 53 | } i_un; |
| 54 | short i_vfdcnt; /* number of fd's vreading this inode */ |
| 55 | short i_hlink; /* link in hash chain (iget/iput/ifind) */ |
| 56 | }; |
| 57 | |
| 58 | #ifdef KERNEL |
| 59 | struct inode *inode, *inodeNINODE; |
| 60 | int ninode; |
| 61 | |
| 62 | struct inode *rootdir; /* pointer to inode of root directory */ |
| 63 | struct inode *mpxip; /* mpx virtual inode */ |
| 64 | |
| 65 | struct inode *ialloc(); |
| 66 | struct inode *ifind(); |
| 67 | struct inode *iget(); |
| 68 | struct inode *owner(); |
| 69 | struct inode *maknode(); |
| 70 | struct inode *namei(); |
| 71 | #endif |
| 72 | |
| 73 | /* flags */ |
| 74 | #define ILOCK 01 /* inode is locked */ |
| 75 | #define IUPD 02 /* file has been modified */ |
| 76 | #define IACC 04 /* inode access time to be updated */ |
| 77 | #define IMOUNT 010 /* inode is mounted on */ |
| 78 | #define IWANT 020 /* some process waiting on lock */ |
| 79 | #define ITEXT 040 /* inode is pure text prototype */ |
| 80 | #define ICHG 0100 /* inode has been changed */ |
| 81 | #define IPIPE 0200 /* inode is a pipe */ |
| 82 | |
| 83 | /* modes */ |
| 84 | #define IFMT 0170000 /* type of file */ |
| 85 | #define IFDIR 0040000 /* directory */ |
| 86 | #define IFCHR 0020000 /* character special */ |
| 87 | #define IFBLK 0060000 /* block special */ |
| 88 | #define IFREG 0100000 /* regular */ |
| 89 | #define IFMPC 0030000 /* multiplexed char special */ |
| 90 | #define IFMPB 0070000 /* multiplexed block special */ |
| 91 | #define ISUID 04000 /* set user id on execution */ |
| 92 | #define ISGID 02000 /* set group id on execution */ |
| 93 | #define ISVTX 01000 /* save swapped text even after use */ |
| 94 | #define IREAD 0400 /* read, write, execute permissions */ |
| 95 | #define IWRITE 0200 |
| 96 | #define IEXEC 0100 |