Rev 2404 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2404 | Rev 2435 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
30 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
32 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34 | */ |
34 | */ |
35 | 35 | ||
- | 36 | /** @addtogroup FileSystemImpl |
|
- | 37 | * @{ |
|
- | 38 | */ |
|
36 | 39 | ||
- | 40 | /** |
|
- | 41 | * @file inode.c |
|
37 | /* This file manages the inode table. There are procedures to allocate and |
42 | * @brief This file manages the inode table. There are procedures to allocate and |
38 | * deallocate inodes, acquire, erase, and release them, and read and write |
43 | * deallocate inodes, acquire, erase, and release them, and read and write |
39 | * them from the disk. |
44 | * them from the disk. |
40 | */ |
45 | */ |
41 | 46 | ||
42 | /* Methods: |
- | |
43 | * get_inode: search inode table for a given inode; if not there, read it |
- | |
44 | * read_inode: read a disk block and extract an inode |
- | |
45 | * v1_copy_inode copy from disk inode (V1.x) to in-memory inode struct |
- | |
46 | * v2_copy_inode copy from disk inode (V2.x) to in-memory inode structs |
- | |
47 | * put_inode indicate that an inode is no longer needed in memory |
- | |
48 | * dup_inode: indicate that someone else is using an inode table entry |
- | |
49 | */ |
- | |
50 | - | ||
51 | #include "fs.h" |
47 | #include "fs.h" |
52 | #include "block.h" |
48 | #include "block.h" |
53 | #include "file.h" |
49 | #include "file.h" |
54 | #include "fproc.h" |
50 | #include "fproc.h" |
55 | #include "inode.h" |
51 | #include "inode.h" |
56 | #include "super.h" |
52 | #include "super.h" |
57 | 53 | ||
58 | - | ||
59 | inode_t inode[NR_INODES]; |
54 | inode_t inode[NR_INODES]; /**< A variable to store inode entries */ |
60 | 55 | ||
61 | static void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal); |
56 | static void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal); |
62 | static void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal); |
57 | static void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal); |
63 | 58 | ||
64 | 59 | /** |
|
- | 60 | * Search inode table for a given inode; if not there, read it |
|
- | 61 | */ |
|
65 | inode_t *get_inode(int numb) |
62 | inode_t *get_inode(int numb) |
66 | { |
63 | { |
67 | /* Find a slot in the inode table, load the specified inode into it, and |
64 | /* Find a slot in the inode table, load the specified inode into it, and |
68 | * return a pointer to the slot. |
65 | * return a pointer to the slot. |
69 | */ |
66 | */ |
Line 98... | Line 95... | ||
98 | read_inode(xp); |
95 | read_inode(xp); |
99 | 96 | ||
100 | return xp; |
97 | return xp; |
101 | } |
98 | } |
102 | 99 | ||
- | 100 | /** |
|
- | 101 | * Read a disk block and extract an inode |
|
- | 102 | */ |
|
103 | void read_inode(register inode_t *rip) |
103 | void read_inode(register inode_t *rip) |
104 | { |
104 | { |
105 | 105 | ||
106 | /* An entry in the inode table is to be copied from the disk. */ |
106 | /* An entry in the inode table is to be copied from the disk. */ |
107 | 107 | ||
Line 126... | Line 126... | ||
126 | } |
126 | } |
127 | else { |
127 | else { |
128 | v2_copy_inode(rip, dip2, sp->s_native); |
128 | v2_copy_inode(rip, dip2, sp->s_native); |
129 | } |
129 | } |
130 | } |
130 | } |
131 | 131 | ||
- | 132 | /** |
|
- | 133 | * Copy from disk inode (V1.x) to in-memory inode struct |
|
- | 134 | */ |
|
132 | void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal) |
135 | void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal) |
133 | { |
136 | { |
134 | - | ||
135 | - | ||
136 | /* The V1.x IBM disk, the V1.x 68000 disk, and the V2 disk (same for IBM and |
137 | /* The V1.x IBM disk, the V1.x 68000 disk, and the V2 disk (same for IBM and |
137 | * 68000) all have different inode layouts. When an inode is read or written |
138 | * 68000) all have different inode layouts. When an inode is read or written |
138 | * this routine handles the conversions so that the information in the inode |
139 | * this routine handles the conversions so that the information in the inode |
139 | * table is independent of the disk structure from which the inode came. |
140 | * table is independent of the disk structure from which the inode came. |
140 | * This routine copies from V1 disks. |
141 | * This routine copies from V1 disks. |
Line 154... | Line 155... | ||
154 | rip->i_nindirs = V1_INDIRECTS; |
155 | rip->i_nindirs = V1_INDIRECTS; |
155 | 156 | ||
156 | for (i = 0; i < V1_NR_TZONES; i++) |
157 | for (i = 0; i < V1_NR_TZONES; i++) |
157 | rip->i_zone[i] = conv2(normal, dip->d1_zone[i]); |
158 | rip->i_zone[i] = conv2(normal, dip->d1_zone[i]); |
158 | } |
159 | } |
159 | 160 | ||
- | 161 | /** |
|
- | 162 | * Copy from disk inode (V2.x) to in-memory inode structs |
|
- | 163 | */ |
|
160 | void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal) |
164 | void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal) |
161 | { |
165 | { |
162 | - | ||
163 | - | ||
164 | /* Same as old_icopy, but to/from V2 disk layout. */ |
166 | /* Same as old_icopy, but to/from V2 disk layout. */ |
165 | 167 | ||
166 | int i; |
168 | int i; |
167 | 169 | ||
168 | /* Some check is made for valid number of inode. */ |
170 | /* Some check is made for valid number of inode. */ |
Line 178... | Line 180... | ||
178 | 180 | ||
179 | for (i = 0; i < V2_NR_TZONES; i++) |
181 | for (i = 0; i < V2_NR_TZONES; i++) |
180 | rip->i_zone[i] = conv4(normal, dip->d2_zone[i]); |
182 | rip->i_zone[i] = conv4(normal, dip->d2_zone[i]); |
181 | } |
183 | } |
182 | 184 | ||
- | 185 | /** |
|
- | 186 | * Indicate that an inode is no longer needed in memory |
|
- | 187 | */ |
|
183 | void put_inode(inode_t *rip) |
188 | void put_inode(inode_t *rip) |
184 | { |
189 | { |
185 | 190 | ||
186 | /* The caller is no longer using this inode. */ |
191 | /* The caller is no longer using this inode. */ |
187 | 192 | ||
188 | if (rip == NIL_INODE) |
193 | if (rip == NIL_INODE) |
189 | return; |
194 | return; |
190 | 195 | ||
191 | rip->i_count--; |
196 | rip->i_count--; |
192 | } |
197 | } |
193 | 198 | ||
- | 199 | /** |
|
- | 200 | * Indicate that someone else is using an inode table entry |
|
- | 201 | */ |
|
194 | void dup_inode(inode_t *rip) |
202 | void dup_inode(inode_t *rip) |
195 | { |
203 | { |
196 | 204 | ||
197 | /* This routine is a simplified form of get_inode() for the case where |
205 | /* This routine is a simplified form of get_inode() for the case where |
198 | * the inode pointer is already known. |
206 | * the inode pointer is already known. |
Line 202... | Line 210... | ||
202 | return; |
210 | return; |
203 | 211 | ||
204 | rip->i_count++; |
212 | rip->i_count++; |
205 | } |
213 | } |
206 | 214 | ||
- | 215 | ||
- | 216 | /** |
|
- | 217 | * } |
|
- | 218 | */ |
|
- | 219 |