Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
6d0f0ece KM |
2 | * Copyright (c) 1982, 1989 The Regents of the University of California. |
3 | * All rights reserved. | |
da7c5cc6 | 4 | * |
beeb3369 | 5 | * %sccs.include.redist.c% |
6d0f0ece | 6 | * |
ef5464f2 | 7 | * @(#)inode.h 7.22 (Berkeley) %G% |
da7c5cc6 | 8 | */ |
d0064d3a | 9 | |
9abdb11d | 10 | #include <ufs/ufs/dinode.h> |
be213d5e | 11 | |
d0064d3a | 12 | /* |
409536a4 KM |
13 | * The inode is used to describe each active (or recently active) |
14 | * file in the UFS filesystem. It is composed of two types of | |
15 | * information. The first part is the information that is needed | |
16 | * only while the file is active (such as the identity of the file | |
17 | * and linkage to speed its lookup). The second part is the | |
18 | * permannent meta-data associated with the file which is read | |
19 | * in from the permanent dinode from long term storage when the | |
20 | * file becomes active, and is put back when the file is no longer | |
21 | * being used. | |
d0064d3a | 22 | */ |
a59abf09 | 23 | struct inode { |
be213d5e KM |
24 | struct inode *i_chain[2]; /* hash chain, MUST be first */ |
25 | struct vnode *i_vnode; /* vnode associated with this inode */ | |
6d0f0ece | 26 | struct vnode *i_devvp; /* vnode for block I/O */ |
0997b03c | 27 | u_long i_flag; /* see below */ |
d0064d3a | 28 | dev_t i_dev; /* device where inode resides */ |
200c8b2d | 29 | short i_pad; |
409536a4 | 30 | ino_t i_number; /* the identity of the inode */ |
9abdb11d KB |
31 | union { /* associated filesystem */ |
32 | struct fs *fs; /* FFS */ | |
33 | struct lfs *lfs; /* LFS */ | |
34 | } inode_u; | |
35 | #define i_fs inode_u.fs | |
36 | #define i_lfs inode_u.lfs | |
8923104b | 37 | struct dquot *i_dquot[MAXQUOTAS]; /* pointer to dquot structures */ |
409536a4 | 38 | struct lockf *i_lockf; /* head of byte-level lock list */ |
c0f23154 | 39 | u_quad_t i_modrev; /* revision level for lease */ |
200c8b2d KM |
40 | pid_t i_lockholder; /* DEBUG: holder of inode lock */ |
41 | pid_t i_lockwaiter; /* DEBUG: latest blocked for inode lock */ | |
ec2e7de9 KM |
42 | /* |
43 | * Side effects; used during directory lookup. | |
44 | */ | |
45 | off_t i_endoff; /* end of useful stuff in directory */ | |
46 | long i_diroff; /* offset in dir, where we found last entry */ | |
47 | long i_offset; /* offset of free space in directory */ | |
48 | long i_count; /* size of free slot in directory */ | |
49 | ino_t i_ino; /* inode number of found directory */ | |
50 | u_long i_reclen; /* size of found directory entry */ | |
51 | /* | |
52 | * the on-disk dinode itself. | |
53 | */ | |
409536a4 | 54 | struct dinode i_din; /* the on-disk dinode */ |
ec2e7de9 | 55 | long i_spare[12]; /* spares to round up to 256 bytes */ |
d0064d3a BJ |
56 | }; |
57 | ||
be213d5e KM |
58 | #define i_mode i_din.di_mode |
59 | #define i_nlink i_din.di_nlink | |
60 | #define i_uid i_din.di_uid | |
61 | #define i_gid i_din.di_gid | |
c0f23154 KM |
62 | #ifdef _NOQUAD |
63 | #define i_size i_din.di_qsize.val[_QUAD_LOWWORD] | |
64 | #else | |
65 | #define i_size i_din.di_qsize | |
66 | #endif | |
67 | #if defined(tahoe) /* ugh! -- must be fixed */ | |
68 | #undef i_size | |
be213d5e | 69 | #define i_size i_din.di_qsize.val[0] |
961945a8 | 70 | #endif |
be213d5e KM |
71 | #define i_db i_din.di_db |
72 | #define i_ib i_din.di_ib | |
73 | #define i_atime i_din.di_atime | |
74 | #define i_mtime i_din.di_mtime | |
75 | #define i_ctime i_din.di_ctime | |
76 | #define i_blocks i_din.di_blocks | |
77 | #define i_rdev i_din.di_db[0] | |
78 | #define i_flags i_din.di_flags | |
79 | #define i_gen i_din.di_gen | |
69bd12a8 RE |
80 | #define i_forw i_chain[0] |
81 | #define i_back i_chain[1] | |
ad30fb67 | 82 | |
d0064d3a | 83 | /* flags */ |
771f4649 KM |
84 | #define ILOCKED 0x0001 /* inode is locked */ |
85 | #define IWANT 0x0002 /* some process waiting on lock */ | |
86 | #define IRENAME 0x0004 /* inode is being renamed */ | |
87 | #define IUPD 0x0010 /* file has been modified */ | |
88 | #define IACC 0x0020 /* inode access time to be updated */ | |
89 | #define ICHG 0x0040 /* inode has been changed */ | |
90 | #define IMOD 0x0080 /* inode has been modified */ | |
91 | #define ISHLOCK 0x0100 /* file has shared lock */ | |
92 | #define IEXLOCK 0x0200 /* file has exclusive lock */ | |
93 | #define ILWAIT 0x0400 /* someone waiting on file lock */ | |
d0064d3a | 94 | |
6d0f0ece | 95 | #ifdef KERNEL |
9abdb11d | 96 | /* Convert between inode pointers and vnode pointers. */ |
6d0f0ece | 97 | #define VTOI(vp) ((struct inode *)(vp)->v_data) |
be213d5e | 98 | #define ITOV(ip) ((ip)->i_vnode) |
6d0f0ece | 99 | |
9abdb11d | 100 | /* Lock and unlock inodes. */ |
30fd732d | 101 | #ifdef notdef |
02dd5a44 BJ |
102 | #define ILOCK(ip) { \ |
103 | while ((ip)->i_flag & ILOCKED) { \ | |
104 | (ip)->i_flag |= IWANT; \ | |
6d0f0ece | 105 | (void) sleep((caddr_t)(ip), PINOD); \ |
02dd5a44 BJ |
106 | } \ |
107 | (ip)->i_flag |= ILOCKED; \ | |
108 | } | |
109 | ||
110 | #define IUNLOCK(ip) { \ | |
111 | (ip)->i_flag &= ~ILOCKED; \ | |
112 | if ((ip)->i_flag&IWANT) { \ | |
113 | (ip)->i_flag &= ~IWANT; \ | |
114 | wakeup((caddr_t)(ip)); \ | |
115 | } \ | |
116 | } | |
30fd732d | 117 | #else |
9abdb11d KB |
118 | #define ILOCK(ip) ufs_ilock(ip) |
119 | #define IUNLOCK(ip) ufs_iunlock(ip) | |
30fd732d | 120 | #endif |
02dd5a44 | 121 | |
232d0cb7 MK |
122 | #define ITIMES(ip, t1, t2) { \ |
123 | if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \ | |
124 | (ip)->i_flag |= IMOD; \ | |
125 | if ((ip)->i_flag&IACC) \ | |
126 | (ip)->i_atime = (t1)->tv_sec; \ | |
c0f23154 | 127 | if ((ip)->i_flag&IUPD) { \ |
232d0cb7 | 128 | (ip)->i_mtime = (t2)->tv_sec; \ |
c0f23154 KM |
129 | INCRQUAD((ip)->i_modrev); \ |
130 | } \ | |
232d0cb7 MK |
131 | if ((ip)->i_flag&ICHG) \ |
132 | (ip)->i_ctime = time.tv_sec; \ | |
133 | (ip)->i_flag &= ~(IACC|IUPD|ICHG); \ | |
134 | } \ | |
135 | } | |
6d0f0ece | 136 | |
9abdb11d | 137 | /* This overlays the fid structure (see mount.h). */ |
6d0f0ece | 138 | struct ufid { |
be213d5e KM |
139 | u_short ufid_len; /* length of structure */ |
140 | u_short ufid_pad; /* force long alignment */ | |
141 | ino_t ufid_ino; /* file number (ino) */ | |
142 | long ufid_gen; /* generation number */ | |
6d0f0ece | 143 | }; |
f1d03a87 | 144 | #endif /* KERNEL */ |