xref: /minix3/minix/fs/mfs/inode.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1 #ifndef __MFS_INODE_H__
2 #define __MFS_INODE_H__
3 
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  *
11  * Updates:
12  * 2007-01-06: jfdsmit@gmail.com added i_zsearch
13  */
14 
15 #include <sys/queue.h>
16 #include <minix/vfsif.h>
17 
18 #include "super.h"
19 
20 EXTERN struct inode {
21   u16_t i_mode;		/* file type, protection, etc. */
22   u16_t i_nlinks;		/* how many links to this file */
23   u16_t i_uid;			/* user id of the file's owner */
24   u16_t i_gid;			/* group number */
25   i32_t i_size;			/* current file size in bytes */
26   u32_t i_atime;		/* time of last access (V2 only) */
27   u32_t i_mtime;		/* when was file data last changed */
28   u32_t i_ctime;		/* when was inode itself changed (V2 only)*/
29   u32_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */
30 
31   /* The following items are not present on the disk. */
32   dev_t i_dev;			/* which device is the inode on */
33   ino_t i_num;			/* inode number on its (minor) device */
34   int i_count;			/* # times inode used; 0 means slot is free */
35   unsigned int i_ndzones;	/* # direct zones (Vx_NR_DZONES) */
36   unsigned int i_nindirs;	/* # indirect zones per indirect block */
37   struct super_block *i_sp;	/* pointer to super block for inode's device */
38   char i_dirt;			/* CLEAN or DIRTY */
39   zone_t i_zsearch;		/* where to start search for new zones */
40   off_t i_last_dpos;		/* where to start dentry search */
41 
42   char i_mountpoint;		/* true if mounted on */
43 
44   char i_seek;			/* set on LSEEK, cleared on READ/WRITE */
45   char i_update;		/* the ATIME, CTIME, and MTIME bits are here */
46 
47   LIST_ENTRY(inode) i_hash;     /* hash list */
48   TAILQ_ENTRY(inode) i_unused;  /* free and unused list */
49 
50 } inode[NR_INODES];
51 
52 /* list of unused/free inodes */
53 EXTERN TAILQ_HEAD(unused_inodes_t, inode)  unused_inodes;
54 
55 /* inode hashtable */
56 EXTERN LIST_HEAD(inodelist, inode)         hash_inodes[INODE_HASH_SIZE];
57 
58 EXTERN unsigned int inode_cache_hit;
59 EXTERN unsigned int inode_cache_miss;
60 
61 
62 /* Field values.  Note that CLEAN and DIRTY are defined in "const.h" */
63 #define NO_SEEK            0	/* i_seek = NO_SEEK if last op was not SEEK */
64 #define ISEEK              1	/* i_seek = ISEEK if last op was SEEK */
65 
66 #define IN_MARKCLEAN(i) i->i_dirt = IN_CLEAN
67 #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)
68 
69 #define IN_ISCLEAN(i) i->i_dirt == IN_CLEAN
70 #define IN_ISDIRTY(i) i->i_dirt == IN_DIRTY
71 
72 #endif
73