1433d6423SLionel Sambuc /* This file manages the inode table. There are procedures to allocate and
2433d6423SLionel Sambuc * deallocate inodes, acquire, erase, and release them, and read and write
3433d6423SLionel Sambuc * them from the disk.
4433d6423SLionel Sambuc *
5433d6423SLionel Sambuc * The entry points into this file are
6433d6423SLionel Sambuc * get_inode: search inode table for a given inode; if not there,
7433d6423SLionel Sambuc * read it
8433d6423SLionel Sambuc * put_inode: indicate that an inode is no longer needed in memory
9433d6423SLionel Sambuc * update_times: update atime, ctime, and mtime
10433d6423SLionel Sambuc * rw_inode: read a disk block and extract an inode, or corresp. write
11433d6423SLionel Sambuc * dup_inode: indicate that someone else is using an inode table entry
12433d6423SLionel Sambuc * find_inode: retrieve pointer to inode in inode cache
13433d6423SLionel Sambuc *
14433d6423SLionel Sambuc * Created (MFS based):
15433d6423SLionel Sambuc * February 2010 (Evgeniy Ivanov)
16433d6423SLionel Sambuc */
17433d6423SLionel Sambuc
18433d6423SLionel Sambuc #include "fs.h"
19433d6423SLionel Sambuc #include <string.h>
20433d6423SLionel Sambuc #include "buf.h"
21433d6423SLionel Sambuc #include "inode.h"
22433d6423SLionel Sambuc #include "super.h"
23433d6423SLionel Sambuc #include <minix/vfsif.h>
24433d6423SLionel Sambuc
25433d6423SLionel Sambuc static void icopy(struct inode *rip, d_inode *dip, int direction, int
26433d6423SLionel Sambuc norm);
27433d6423SLionel Sambuc static void addhash_inode(struct inode *node);
28433d6423SLionel Sambuc static void unhash_inode(struct inode *node);
29433d6423SLionel Sambuc
30433d6423SLionel Sambuc
31433d6423SLionel Sambuc /*===========================================================================*
32433d6423SLionel Sambuc * fs_putnode *
33433d6423SLionel Sambuc *===========================================================================*/
fs_putnode(ino_t ino_nr,unsigned int count)34970d95ecSDavid van Moolenbroek int fs_putnode(ino_t ino_nr, unsigned int count)
35433d6423SLionel Sambuc {
36433d6423SLionel Sambuc /* Find the inode specified by the request message and decrease its counter.*/
37433d6423SLionel Sambuc
38433d6423SLionel Sambuc struct inode *rip;
39433d6423SLionel Sambuc
40970d95ecSDavid van Moolenbroek rip = find_inode(fs_dev, ino_nr);
41433d6423SLionel Sambuc
42433d6423SLionel Sambuc if (!rip) {
43433d6423SLionel Sambuc printf("%s:%d put_inode: inode #%llu dev: %llx not found\n", __FILE__,
44970d95ecSDavid van Moolenbroek __LINE__, ino_nr, fs_dev);
45433d6423SLionel Sambuc panic("fs_putnode failed");
46433d6423SLionel Sambuc }
47433d6423SLionel Sambuc
48970d95ecSDavid van Moolenbroek if (count > rip->i_count) {
49433d6423SLionel Sambuc printf("%s:%d put_inode: count too high: %d > %d\n", __FILE__,
50433d6423SLionel Sambuc __LINE__, count, rip->i_count);
51433d6423SLionel Sambuc panic("fs_putnode failed");
52433d6423SLionel Sambuc }
53433d6423SLionel Sambuc
54433d6423SLionel Sambuc /* Decrease reference counter, but keep one reference;
55433d6423SLionel Sambuc * it will be consumed by put_inode().
56433d6423SLionel Sambuc */
57433d6423SLionel Sambuc rip->i_count -= count - 1;
58433d6423SLionel Sambuc put_inode(rip);
59433d6423SLionel Sambuc
60433d6423SLionel Sambuc return(OK);
61433d6423SLionel Sambuc }
62433d6423SLionel Sambuc
63433d6423SLionel Sambuc
64433d6423SLionel Sambuc /*===========================================================================*
65433d6423SLionel Sambuc * init_inode_cache *
66433d6423SLionel Sambuc *===========================================================================*/
init_inode_cache()67433d6423SLionel Sambuc void init_inode_cache()
68433d6423SLionel Sambuc {
69433d6423SLionel Sambuc struct inode *rip;
70433d6423SLionel Sambuc struct inodelist *rlp;
71433d6423SLionel Sambuc
72433d6423SLionel Sambuc inode_cache_hit = 0;
73433d6423SLionel Sambuc inode_cache_miss = 0;
74433d6423SLionel Sambuc
75433d6423SLionel Sambuc /* init free/unused list */
76433d6423SLionel Sambuc TAILQ_INIT(&unused_inodes);
77433d6423SLionel Sambuc
78433d6423SLionel Sambuc /* init hash lists */
79433d6423SLionel Sambuc for (rlp = &hash_inodes[0]; rlp < &hash_inodes[INODE_HASH_SIZE]; ++rlp)
80433d6423SLionel Sambuc LIST_INIT(rlp);
81433d6423SLionel Sambuc
82433d6423SLionel Sambuc /* add free inodes to unused/free list */
83433d6423SLionel Sambuc for (rip = &inode[0]; rip < &inode[NR_INODES]; ++rip) {
84433d6423SLionel Sambuc rip->i_num = NO_ENTRY;
85433d6423SLionel Sambuc TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused);
86433d6423SLionel Sambuc }
87433d6423SLionel Sambuc }
88433d6423SLionel Sambuc
89433d6423SLionel Sambuc
90433d6423SLionel Sambuc /*===========================================================================*
91433d6423SLionel Sambuc * addhash_inode *
92433d6423SLionel Sambuc *===========================================================================*/
addhash_inode(struct inode * node)93433d6423SLionel Sambuc static void addhash_inode(struct inode *node)
94433d6423SLionel Sambuc {
95433d6423SLionel Sambuc int hashi = node->i_num & INODE_HASH_MASK;
96433d6423SLionel Sambuc
97433d6423SLionel Sambuc /* insert into hash table */
98433d6423SLionel Sambuc LIST_INSERT_HEAD(&hash_inodes[hashi], node, i_hash);
99433d6423SLionel Sambuc }
100433d6423SLionel Sambuc
101433d6423SLionel Sambuc
102433d6423SLionel Sambuc /*===========================================================================*
103433d6423SLionel Sambuc * unhash_inode *
104433d6423SLionel Sambuc *===========================================================================*/
unhash_inode(struct inode * node)105433d6423SLionel Sambuc static void unhash_inode(struct inode *node)
106433d6423SLionel Sambuc {
107433d6423SLionel Sambuc /* remove from hash table */
108433d6423SLionel Sambuc LIST_REMOVE(node, i_hash);
109433d6423SLionel Sambuc }
110433d6423SLionel Sambuc
111433d6423SLionel Sambuc
112433d6423SLionel Sambuc /*===========================================================================*
113433d6423SLionel Sambuc * get_inode *
114433d6423SLionel Sambuc *===========================================================================*/
get_inode(dev_t dev,ino_t numb)115433d6423SLionel Sambuc struct inode *get_inode(
116433d6423SLionel Sambuc dev_t dev, /* device on which inode resides */
117433d6423SLionel Sambuc ino_t numb /* inode number (ANSI: may not be unshort) */
118433d6423SLionel Sambuc )
119433d6423SLionel Sambuc {
120433d6423SLionel Sambuc /* Find the inode in the hash table. If it is not there, get a free inode
121433d6423SLionel Sambuc * load it from the disk if it's necessary and put on the hash list
122433d6423SLionel Sambuc */
123433d6423SLionel Sambuc register struct inode *rip;
124433d6423SLionel Sambuc int hashi;
125433d6423SLionel Sambuc int i;
126433d6423SLionel Sambuc
127433d6423SLionel Sambuc hashi = (int) numb & INODE_HASH_MASK;
128433d6423SLionel Sambuc
129433d6423SLionel Sambuc /* Search inode in the hash table */
130433d6423SLionel Sambuc LIST_FOREACH(rip, &hash_inodes[hashi], i_hash) {
131433d6423SLionel Sambuc if (rip->i_num == numb && rip->i_dev == dev) {
132433d6423SLionel Sambuc /* If unused, remove it from the unused/free list */
133433d6423SLionel Sambuc if (rip->i_count == 0) {
134433d6423SLionel Sambuc inode_cache_hit++;
135433d6423SLionel Sambuc TAILQ_REMOVE(&unused_inodes, rip, i_unused);
136433d6423SLionel Sambuc }
137433d6423SLionel Sambuc ++rip->i_count;
138433d6423SLionel Sambuc return(rip);
139433d6423SLionel Sambuc }
140433d6423SLionel Sambuc }
141433d6423SLionel Sambuc
142433d6423SLionel Sambuc inode_cache_miss++;
143433d6423SLionel Sambuc
144433d6423SLionel Sambuc /* Inode is not on the hash, get a free one */
145433d6423SLionel Sambuc if (TAILQ_EMPTY(&unused_inodes)) {
146433d6423SLionel Sambuc err_code = ENFILE;
147433d6423SLionel Sambuc return(NULL);
148433d6423SLionel Sambuc }
149433d6423SLionel Sambuc rip = TAILQ_FIRST(&unused_inodes);
150433d6423SLionel Sambuc
151433d6423SLionel Sambuc /* If not free unhash it */
152433d6423SLionel Sambuc if (rip->i_num != NO_ENTRY)
153433d6423SLionel Sambuc unhash_inode(rip);
154433d6423SLionel Sambuc
155433d6423SLionel Sambuc /* Inode is not unused any more */
156433d6423SLionel Sambuc TAILQ_REMOVE(&unused_inodes, rip, i_unused);
157433d6423SLionel Sambuc
158433d6423SLionel Sambuc /* Load the inode. */
159433d6423SLionel Sambuc rip->i_dev = dev;
160433d6423SLionel Sambuc rip->i_num = numb;
161433d6423SLionel Sambuc rip->i_count = 1;
162433d6423SLionel Sambuc if (dev != NO_DEV)
163433d6423SLionel Sambuc rw_inode(rip, READING); /* get inode from disk */
164433d6423SLionel Sambuc rip->i_update = 0; /* all the times are initially up-to-date */
165433d6423SLionel Sambuc rip->i_last_dpos = 0; /* no dentries searched for yet */
166433d6423SLionel Sambuc rip->i_bsearch = NO_BLOCK;
167433d6423SLionel Sambuc rip->i_last_pos_bl_alloc = 0;
168433d6423SLionel Sambuc rip->i_last_dentry_size = 0;
169433d6423SLionel Sambuc rip->i_mountpoint= FALSE;
170433d6423SLionel Sambuc
171433d6423SLionel Sambuc rip->i_preallocation = opt.use_prealloc;
172433d6423SLionel Sambuc rip->i_prealloc_count = rip->i_prealloc_index = 0;
173433d6423SLionel Sambuc
174433d6423SLionel Sambuc for (i = 0; i < EXT2_PREALLOC_BLOCKS; i++) {
175433d6423SLionel Sambuc if (rip->i_prealloc_blocks[i] != NO_BLOCK) {
176433d6423SLionel Sambuc /* Actually this should never happen */
177433d6423SLionel Sambuc free_block(rip->i_sp, rip->i_prealloc_blocks[i]);
178433d6423SLionel Sambuc rip->i_prealloc_blocks[i] = NO_BLOCK;
179433d6423SLionel Sambuc ext2_debug("Warning: Unexpected preallocated block.");
180433d6423SLionel Sambuc }
181433d6423SLionel Sambuc }
182433d6423SLionel Sambuc
183433d6423SLionel Sambuc /* Add to hash */
184433d6423SLionel Sambuc addhash_inode(rip);
185433d6423SLionel Sambuc
186433d6423SLionel Sambuc return(rip);
187433d6423SLionel Sambuc }
188433d6423SLionel Sambuc
189433d6423SLionel Sambuc
190433d6423SLionel Sambuc /*===========================================================================*
191433d6423SLionel Sambuc * find_inode *
192433d6423SLionel Sambuc *===========================================================================*/
find_inode(dev_t dev,ino_t numb)193433d6423SLionel Sambuc struct inode *find_inode(
194433d6423SLionel Sambuc dev_t dev, /* device on which inode resides */
195433d6423SLionel Sambuc ino_t numb /* inode number (ANSI: may not be unshort) */
196433d6423SLionel Sambuc )
197433d6423SLionel Sambuc {
198433d6423SLionel Sambuc /* Find the inode specified by the inode and device number. */
199433d6423SLionel Sambuc struct inode *rip;
200433d6423SLionel Sambuc int hashi;
201433d6423SLionel Sambuc
202433d6423SLionel Sambuc hashi = (int) numb & INODE_HASH_MASK;
203433d6423SLionel Sambuc
204433d6423SLionel Sambuc /* Search inode in the hash table */
205433d6423SLionel Sambuc LIST_FOREACH(rip, &hash_inodes[hashi], i_hash) {
206433d6423SLionel Sambuc if (rip->i_count > 0 && rip->i_num == numb && rip->i_dev == dev) {
207433d6423SLionel Sambuc return(rip);
208433d6423SLionel Sambuc }
209433d6423SLionel Sambuc }
210433d6423SLionel Sambuc
211433d6423SLionel Sambuc return(NULL);
212433d6423SLionel Sambuc }
213433d6423SLionel Sambuc
214433d6423SLionel Sambuc
215433d6423SLionel Sambuc /*===========================================================================*
216433d6423SLionel Sambuc * put_inode *
217433d6423SLionel Sambuc *===========================================================================*/
put_inode(register struct inode * rip)218433d6423SLionel Sambuc void put_inode(
219433d6423SLionel Sambuc register struct inode *rip /* pointer to inode to be released */
220433d6423SLionel Sambuc )
221433d6423SLionel Sambuc {
222433d6423SLionel Sambuc /* The caller is no longer using this inode. If no one else is using it either
223433d6423SLionel Sambuc * write it back to the disk immediately. If it has no links, truncate it and
224433d6423SLionel Sambuc * return it to the pool of available inodes.
225433d6423SLionel Sambuc */
226433d6423SLionel Sambuc
227433d6423SLionel Sambuc if (rip == NULL)
228433d6423SLionel Sambuc return; /* checking here is easier than in caller */
229433d6423SLionel Sambuc
230433d6423SLionel Sambuc if (rip->i_count < 1)
231433d6423SLionel Sambuc panic("put_inode: i_count already below 1: %d", rip->i_count);
232433d6423SLionel Sambuc
233433d6423SLionel Sambuc if (--rip->i_count == 0) { /* i_count == 0 means no one is using it now */
234433d6423SLionel Sambuc if (rip->i_links_count == NO_LINK) {
235433d6423SLionel Sambuc /* i_nlinks == NO_LINK means free the inode. */
236433d6423SLionel Sambuc /* return all the disk blocks */
237433d6423SLionel Sambuc
238433d6423SLionel Sambuc /* Ignore errors by truncate_inode in case inode is a block
239433d6423SLionel Sambuc * special or character special file.
240433d6423SLionel Sambuc */
241433d6423SLionel Sambuc (void) truncate_inode(rip, (off_t) 0);
242433d6423SLionel Sambuc /* free inode clears I_TYPE field, since it's used there */
243433d6423SLionel Sambuc rip->i_dirt = IN_DIRTY;
244433d6423SLionel Sambuc free_inode(rip);
245433d6423SLionel Sambuc }
246433d6423SLionel Sambuc
247433d6423SLionel Sambuc rip->i_mountpoint = FALSE;
248433d6423SLionel Sambuc if (rip->i_dirt == IN_DIRTY) rw_inode(rip, WRITING);
249433d6423SLionel Sambuc
250433d6423SLionel Sambuc discard_preallocated_blocks(rip); /* Return blocks to the filesystem */
251433d6423SLionel Sambuc
252433d6423SLionel Sambuc if (rip->i_links_count == NO_LINK) {
253433d6423SLionel Sambuc /* free, put at the front of the LRU list */
254433d6423SLionel Sambuc unhash_inode(rip);
255433d6423SLionel Sambuc rip->i_num = NO_ENTRY;
256433d6423SLionel Sambuc TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused);
257433d6423SLionel Sambuc } else {
258433d6423SLionel Sambuc /* unused, put at the back of the LRU (cache it) */
259433d6423SLionel Sambuc TAILQ_INSERT_TAIL(&unused_inodes, rip, i_unused);
260433d6423SLionel Sambuc }
261433d6423SLionel Sambuc }
262433d6423SLionel Sambuc }
263433d6423SLionel Sambuc
264433d6423SLionel Sambuc
265433d6423SLionel Sambuc /*===========================================================================*
266433d6423SLionel Sambuc * update_times *
267433d6423SLionel Sambuc *===========================================================================*/
update_times(register struct inode * rip)268433d6423SLionel Sambuc void update_times(
269433d6423SLionel Sambuc register struct inode *rip /* pointer to inode to be read/written */
270433d6423SLionel Sambuc )
271433d6423SLionel Sambuc {
272433d6423SLionel Sambuc /* Various system calls are required by the standard to update atime, ctime,
273433d6423SLionel Sambuc * or mtime. Since updating a time requires sending a message to the clock
274433d6423SLionel Sambuc * task--an expensive business--the times are marked for update by setting
275433d6423SLionel Sambuc * bits in i_update. When a stat, fstat, or sync is done, or an inode is
276433d6423SLionel Sambuc * released, update_times() may be called to actually fill in the times.
277433d6423SLionel Sambuc */
278433d6423SLionel Sambuc
279433d6423SLionel Sambuc time_t cur_time;
280433d6423SLionel Sambuc struct super_block *sp;
281433d6423SLionel Sambuc
282433d6423SLionel Sambuc sp = rip->i_sp; /* get pointer to super block. */
283433d6423SLionel Sambuc if (sp->s_rd_only)
284433d6423SLionel Sambuc return; /* no updates for read-only file systems */
285433d6423SLionel Sambuc
286ad80a203SDavid van Moolenbroek cur_time = clock_time(NULL);
287433d6423SLionel Sambuc if (rip->i_update & ATIME)
288433d6423SLionel Sambuc rip->i_atime = cur_time;
289433d6423SLionel Sambuc if (rip->i_update & CTIME)
290433d6423SLionel Sambuc rip->i_ctime = cur_time;
291433d6423SLionel Sambuc if (rip->i_update & MTIME)
292433d6423SLionel Sambuc rip->i_mtime = cur_time;
293433d6423SLionel Sambuc rip->i_update = 0; /* they are all up-to-date now */
294433d6423SLionel Sambuc }
295433d6423SLionel Sambuc
296433d6423SLionel Sambuc /*===========================================================================*
297433d6423SLionel Sambuc * rw_inode *
298433d6423SLionel Sambuc *===========================================================================*/
rw_inode(register struct inode * rip,int rw_flag)299433d6423SLionel Sambuc void rw_inode(
300433d6423SLionel Sambuc register struct inode *rip, /* pointer to inode to be read/written */
301433d6423SLionel Sambuc int rw_flag /* READING or WRITING */
302433d6423SLionel Sambuc )
303433d6423SLionel Sambuc {
304433d6423SLionel Sambuc /* An entry in the inode table is to be copied to or from the disk. */
305433d6423SLionel Sambuc
306433d6423SLionel Sambuc register struct buf *bp;
307433d6423SLionel Sambuc register struct super_block *sp;
308433d6423SLionel Sambuc register struct group_desc *gd;
309433d6423SLionel Sambuc register d_inode *dip;
310433d6423SLionel Sambuc u32_t block_group_number;
311433d6423SLionel Sambuc block_t b, offset;
312433d6423SLionel Sambuc
313433d6423SLionel Sambuc /* Get the block where the inode resides. */
314433d6423SLionel Sambuc sp = get_super(rip->i_dev); /* get pointer to super block */
315433d6423SLionel Sambuc rip->i_sp = sp; /* inode must contain super block pointer */
316433d6423SLionel Sambuc
317433d6423SLionel Sambuc block_group_number = (rip->i_num - 1) / sp->s_inodes_per_group;
318433d6423SLionel Sambuc
319433d6423SLionel Sambuc gd = get_group_desc(block_group_number);
320433d6423SLionel Sambuc
321433d6423SLionel Sambuc if (gd == NULL)
322433d6423SLionel Sambuc panic("can't get group_desc to read/write inode");
323433d6423SLionel Sambuc
324433d6423SLionel Sambuc offset = ((rip->i_num - 1) % sp->s_inodes_per_group) * EXT2_INODE_SIZE(sp);
325433d6423SLionel Sambuc /* offset requires shifting, since each block contains several inodes,
326433d6423SLionel Sambuc * e.g. inode 2 is stored in bklock 0.
327433d6423SLionel Sambuc */
328433d6423SLionel Sambuc b = (block_t) gd->inode_table + (offset >> sp->s_blocksize_bits);
329433d6423SLionel Sambuc bp = get_block(rip->i_dev, b, NORMAL);
330433d6423SLionel Sambuc
331433d6423SLionel Sambuc offset &= (sp->s_block_size - 1);
332433d6423SLionel Sambuc dip = (d_inode*) (b_data(bp) + offset);
333433d6423SLionel Sambuc
334433d6423SLionel Sambuc /* Do the read or write. */
335433d6423SLionel Sambuc if (rw_flag == WRITING) {
336433d6423SLionel Sambuc if (rip->i_update)
337433d6423SLionel Sambuc update_times(rip); /* times need updating */
338433d6423SLionel Sambuc if (sp->s_rd_only == FALSE)
339433d6423SLionel Sambuc lmfs_markdirty(bp);
340433d6423SLionel Sambuc }
341433d6423SLionel Sambuc
342433d6423SLionel Sambuc icopy(rip, dip, rw_flag, TRUE);
343433d6423SLionel Sambuc
344*0314acfbSDavid van Moolenbroek put_block(bp);
345433d6423SLionel Sambuc rip->i_dirt = IN_CLEAN;
346433d6423SLionel Sambuc }
347433d6423SLionel Sambuc
348433d6423SLionel Sambuc
349433d6423SLionel Sambuc /*===========================================================================*
350433d6423SLionel Sambuc * icopy *
351433d6423SLionel Sambuc *===========================================================================*/
icopy(register struct inode * rip,register d_inode * dip,int direction,int norm)352433d6423SLionel Sambuc static void icopy(
353433d6423SLionel Sambuc register struct inode *rip, /* pointer to the in-core inode struct */
354433d6423SLionel Sambuc register d_inode *dip, /* pointer to the on-disk struct */
355433d6423SLionel Sambuc int direction, /* READING (from disk) or WRITING (to disk) */
356433d6423SLionel Sambuc int norm /* TRUE = do not swap bytes; FALSE = swap */
357433d6423SLionel Sambuc )
358433d6423SLionel Sambuc {
359433d6423SLionel Sambuc int i;
360433d6423SLionel Sambuc
361433d6423SLionel Sambuc if (direction == READING) {
362433d6423SLionel Sambuc /* Copy inode to the in-core table, swapping bytes if need be. */
363433d6423SLionel Sambuc rip->i_mode = conv2(norm,dip->i_mode);
364433d6423SLionel Sambuc rip->i_uid = conv2(norm,dip->i_uid);
365433d6423SLionel Sambuc rip->i_size = conv4(norm,dip->i_size);
366433d6423SLionel Sambuc rip->i_atime = conv4(norm,dip->i_atime);
367433d6423SLionel Sambuc rip->i_ctime = conv4(norm,dip->i_ctime);
368433d6423SLionel Sambuc rip->i_mtime = conv4(norm,dip->i_mtime);
369433d6423SLionel Sambuc rip->i_dtime = conv4(norm,dip->i_dtime);
370433d6423SLionel Sambuc rip->i_gid = conv2(norm,dip->i_gid);
371433d6423SLionel Sambuc rip->i_links_count = conv2(norm,dip->i_links_count);
372433d6423SLionel Sambuc rip->i_blocks = conv4(norm,dip->i_blocks);
373433d6423SLionel Sambuc rip->i_flags = conv4(norm,dip->i_flags);
374433d6423SLionel Sambuc /* Minix doesn't touch osd1 and osd2 either, so just copy. */
375433d6423SLionel Sambuc memcpy(&rip->osd1, &dip->osd1, sizeof(rip->osd1));
376433d6423SLionel Sambuc for (i = 0; i < EXT2_N_BLOCKS; i++)
377433d6423SLionel Sambuc rip->i_block[i] = conv4(norm, dip->i_block[i]);
378433d6423SLionel Sambuc rip->i_generation = conv4(norm,dip->i_generation);
379433d6423SLionel Sambuc rip->i_file_acl = conv4(norm,dip->i_file_acl);
380433d6423SLionel Sambuc rip->i_dir_acl = conv4(norm,dip->i_dir_acl);
381433d6423SLionel Sambuc rip->i_faddr = conv4(norm,dip->i_faddr);
382433d6423SLionel Sambuc memcpy(&rip->osd2, &dip->osd2, sizeof(rip->osd2));
383433d6423SLionel Sambuc } else {
384433d6423SLionel Sambuc /* Copying inode to disk from the in-core table. */
385433d6423SLionel Sambuc dip->i_mode = conv2(norm,rip->i_mode);
386433d6423SLionel Sambuc dip->i_uid = conv2(norm,rip->i_uid);
387433d6423SLionel Sambuc dip->i_size = conv4(norm,rip->i_size);
388433d6423SLionel Sambuc dip->i_atime = conv4(norm,rip->i_atime);
389433d6423SLionel Sambuc dip->i_ctime = conv4(norm,rip->i_ctime);
390433d6423SLionel Sambuc dip->i_mtime = conv4(norm,rip->i_mtime);
391433d6423SLionel Sambuc dip->i_dtime = conv4(norm,rip->i_dtime);
392433d6423SLionel Sambuc dip->i_gid = conv2(norm,rip->i_gid);
393433d6423SLionel Sambuc dip->i_links_count = conv2(norm,rip->i_links_count);
394433d6423SLionel Sambuc dip->i_blocks = conv4(norm,rip->i_blocks);
395433d6423SLionel Sambuc dip->i_flags = conv4(norm,rip->i_flags);
396433d6423SLionel Sambuc /* Minix doesn't touch osd1 and osd2 either, so just copy. */
397433d6423SLionel Sambuc memcpy(&dip->osd1, &rip->osd1, sizeof(dip->osd1));
398433d6423SLionel Sambuc for (i = 0; i < EXT2_N_BLOCKS; i++)
399433d6423SLionel Sambuc dip->i_block[i] = conv4(norm, rip->i_block[i]);
400433d6423SLionel Sambuc dip->i_generation = conv4(norm,rip->i_generation);
401433d6423SLionel Sambuc dip->i_file_acl = conv4(norm,rip->i_file_acl);
402433d6423SLionel Sambuc dip->i_dir_acl = conv4(norm,rip->i_dir_acl);
403433d6423SLionel Sambuc dip->i_faddr = conv4(norm,rip->i_faddr);
404433d6423SLionel Sambuc memcpy(&dip->osd2, &rip->osd2, sizeof(dip->osd2));
405433d6423SLionel Sambuc }
406433d6423SLionel Sambuc }
407433d6423SLionel Sambuc
408433d6423SLionel Sambuc
409433d6423SLionel Sambuc /*===========================================================================*
410433d6423SLionel Sambuc * dup_inode *
411433d6423SLionel Sambuc *===========================================================================*/
dup_inode(struct inode * ip)412433d6423SLionel Sambuc void dup_inode(
413433d6423SLionel Sambuc struct inode *ip /* The inode to be duplicated. */
414433d6423SLionel Sambuc )
415433d6423SLionel Sambuc {
416433d6423SLionel Sambuc /* This routine is a simplified form of get_inode() for the case where
417433d6423SLionel Sambuc * the inode pointer is already known.
418433d6423SLionel Sambuc */
419433d6423SLionel Sambuc ip->i_count++;
420433d6423SLionel Sambuc }
421