|
|
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: dev_t i_dev; /* device where inode resides */
18: char i_fstyp; /* type of its filesystem */
19: unsigned short i_count; /* reference count */
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: } i_d;
41: #define i_rdev i_d.I_rdev
42: struct {
43: long I_tag;
44: struct inode *I_cip; /* communications */
45: int I_fsflags; /* in root inode only */
46: time_t I_atime;
47: time_t I_mtime;
48: time_t I_ctime;
49: dev_t I_rdev;
50: } i_a; /* network filesystems et al */
51: #define i_tag i_a.I_tag
52: #define i_cip i_a.I_cip
53: #define i_fsflags i_a.I_fsflags
54: #define i_netatime i_a.I_atime
55: #define i_netmtime i_a.I_mtime
56: #define i_netctime i_a.I_ctime
57: #define i_netrdev i_a.I_rdev
58: struct {
59: struct proc *I_proc; /* sanity checking */
60: int I_sigmask; /* signal trace mask */
61: } i_p;
62: #define i_proc i_p.I_proc
63: #define i_sigmask i_p.I_sigmask
64: } i_un;
65: struct inode *i_hlink; /* link in hash chain (iget/iput/ifind) */
66: };
67:
68: #ifdef KERNEL
69: extern struct inode inode[];
70: extern struct inode *inodeNINODE;
71: extern int inodecnt;
72:
73: struct inode *rootdir; /* pointer to inode of root directory */
74:
75: struct inode *ialloc();
76: struct inode *ifind();
77: struct inode *iget();
78: struct inode *iuniq();
79: struct inode *namei();
80: struct inode *openi();
81: #endif
82:
83: /* flags */
84: #define ILOCK 01 /* inode is locked */
85: #define IUPD 02 /* file has been modified */
86: #define IACC 04 /* inode access time to be updated */
87: #define IWANT 020 /* some process waiting on lock */
88: #define ITEXT 040 /* inode is pure text prototype */
89: #define ICHG 0100 /* inode has been changed */
90: #define IOPEN 0200 /* has been opened; close on last iput */
91:
92: /* modes */
93: #define IFMT 0170000 /* type of file */
94: #define IFDIR 0040000 /* directory */
95: #define IFCHR 0020000 /* character special */
96: #define IFBLK 0060000 /* block special */
97: #define IFREG 0100000 /* regular */
98: #define IFLNK 0120000 /* symbolic link to another file */
99: #define ISUID 04000 /* set user id on execution */
100: #define ISGID 02000 /* set group id on execution */
101: #define IREAD 0400 /* read, write, execute permissions */
102: #define IWRITE 0200
103: #define IEXEC 0100
104: #define ICONC 0001000 /* this file is protected for concurrent access */
105: #define ICCTYP 0007000 /* type of concurrent access */
106: #define ISYNC 0001000 /* 1 writer and n readers (synchronized access) */
107: #define IEXCL 0003000 /* 1 writer or n readers (exclusive access) */
108:
109: struct argnamei { /* namei's flag argument */
110: short flag; /* type of request */
111: short len; /* length of last component buffer */
112: union {
113: short mode; /* mode for creating */
114: struct inode *il; /* for linking */
115: caddr_t buf; /* where to copy last component for exec */
116: } un;
117: };
118: #define NI_SEARCH 0 /* search only (0 value known to nilargnamei, beware) */
119: #define NI_DEL 1 /* unlink this file */
120: #define NI_CREAT 2 /* create it if it doesn't exits */
121: #define NI_NXCREAT 3 /* create it, error if it already exists */
122: #define NI_LINK 4 /* make a link */
123: #define NI_MKDIR 5 /* make a directory */
124: #define NI_RMDIR 6 /* remove a directory */
125:
126: #ifdef KERNEL
127: extern struct argnamei nilargnamei;
128: #endif
129: struct nx { /* arg to real nami */
130: struct inode *dp; /* current inode */
131: char *cp; /* current position in pathname */
132: char *nbuf; /* pathname being parsed */
133: short nlen; /* length of pathname buffer */
134: short nlink; /* symlinks seen so far */
135: };
136:
137: /*
138: * some inline subroutines to speed things up
139: */
140:
141: #ifdef KERNEL
142:
143: #define plock(ip) \
144: { \
145: while ((ip)->i_flag & ILOCK) { \
146: (ip)->i_flag |= IWANT; \
147: sleep((caddr_t)(ip), PINOD); \
148: } \
149: (ip)->i_flag |= ILOCK; \
150: }
151:
152: #define prele(ip) \
153: { \
154: (ip)->i_flag &= ~ILOCK; \
155: if ((ip)->i_flag&IWANT) { \
156: (ip)->i_flag &= ~IWANT; \
157: wakeup((caddr_t)(ip)); \
158: } \
159: }
160:
161: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.