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