1 #ifndef __MFS_INODE_H__
2 #define __MFS_INODE_H__
4 /* Inode table. This table holds inodes that are currently in use. In some
5 * cases they have been opened by an open() or creat() system call, in other
6 * cases the file system itself needs the inode for one reason or another,
7 * such as to search a directory for a path name.
8 * The first part of the struct holds fields that are present on the
9 * disk; the second part holds fields not present on the disk.
10 * The disk inode part is also declared in "type.h" as 'd1_inode' for V1
11 * file systems and 'd2_inode' for V2 file systems.
14 * 2007-01-06: jfdsmit@gmail.com added i_zsearch
17 #include <sys/queue.h>
22 u16_t i_mode
; /* file type, protection, etc. */
23 u16_t i_nlinks
; /* how many links to this file */
24 u16_t i_uid
; /* user id of the file's owner */
25 u16_t i_gid
; /* group number */
26 i32_t i_size
; /* current file size in bytes */
27 u32_t i_atime
; /* time of last access (V2 only) */
28 u32_t i_mtime
; /* when was file data last changed */
29 u32_t i_ctime
; /* when was inode itself changed (V2 only)*/
30 u32_t i_zone
[V2_NR_TZONES
]; /* zone numbers for direct, ind, and dbl ind */
32 /* The following items are not present on the disk. */
33 dev_t i_dev
; /* which device is the inode on */
34 ino_t i_num
; /* inode number on its (minor) device */
35 int i_count
; /* # times inode used; 0 means slot is free */
36 unsigned int i_ndzones
; /* # direct zones (Vx_NR_DZONES) */
37 unsigned int i_nindirs
; /* # indirect zones per indirect block */
38 struct super_block
*i_sp
; /* pointer to super block for inode's device */
39 char i_dirt
; /* CLEAN or DIRTY */
40 zone_t i_zsearch
; /* where to start search for new zones */
41 off_t i_last_dpos
; /* where to start dentry search */
43 char i_mountpoint
; /* true if mounted on */
45 char i_seek
; /* set on LSEEK, cleared on READ/WRITE */
46 char i_update
; /* the ATIME, CTIME, and MTIME bits are here */
48 LIST_ENTRY(inode
) i_hash
; /* hash list */
49 TAILQ_ENTRY(inode
) i_unused
; /* free and unused list */
53 /* list of unused/free inodes */
54 EXTERN
TAILQ_HEAD(unused_inodes_t
, inode
) unused_inodes
;
57 EXTERN
LIST_HEAD(inodelist
, inode
) hash_inodes
[INODE_HASH_SIZE
];
59 EXTERN
unsigned int inode_cache_hit
;
60 EXTERN
unsigned int inode_cache_miss
;
63 /* Field values. Note that CLEAN and DIRTY are defined in "const.h" */
64 #define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */
65 #define ISEEK 1 /* i_seek = ISEEK if last op was SEEK */
67 #define IN_MARKCLEAN(i) i->i_dirt = IN_CLEAN
68 #define IN_MARKDIRTY(i) do { if(i->i_sp->s_rd_only) { printf("%s:%d: dirty inode on rofs ", __FILE__, __LINE__); util_stacktrace(); } else { i->i_dirt = IN_DIRTY; } } while(0)
70 #define IN_ISCLEAN(i) i->i_dirt == IN_CLEAN
71 #define IN_ISDIRTY(i) i->i_dirt == IN_DIRTY