2010-06-01 14:35:33 +02:00
|
|
|
#ifndef __MFS_INODE_H__
|
|
|
|
#define __MFS_INODE_H__
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
/* Inode table. This table holds inodes that are currently in use. In some
|
|
|
|
* cases they have been opened by an open() or creat() system call, in other
|
|
|
|
* cases the file system itself needs the inode for one reason or another,
|
|
|
|
* such as to search a directory for a path name.
|
|
|
|
* The first part of the struct holds fields that are present on the
|
|
|
|
* disk; the second part holds fields not present on the disk.
|
|
|
|
* The disk inode part is also declared in "type.h" as 'd1_inode' for V1
|
|
|
|
* file systems and 'd2_inode' for V2 file systems.
|
2008-02-06 16:05:57 +01:00
|
|
|
*
|
|
|
|
* Updates:
|
|
|
|
* 2007-01-06: jfdsmit@gmail.com added i_zsearch
|
2005-04-21 16:53:53 +02:00
|
|
|
*/
|
|
|
|
|
2009-04-22 22:02:39 +02:00
|
|
|
#include <sys/queue.h>
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
#include "super.h"
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
EXTERN struct inode {
|
2011-09-05 15:56:14 +02:00
|
|
|
u16_t i_mode; /* file type, protection, etc. */
|
|
|
|
u16_t i_nlinks; /* how many links to this file */
|
|
|
|
u16_t i_uid; /* user id of the file's owner */
|
|
|
|
u16_t i_gid; /* group number */
|
|
|
|
i32_t i_size; /* current file size in bytes */
|
|
|
|
u32_t i_atime; /* time of last access (V2 only) */
|
|
|
|
u32_t i_mtime; /* when was file data last changed */
|
|
|
|
u32_t i_ctime; /* when was inode itself changed (V2 only)*/
|
|
|
|
u32_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* The following items are not present on the disk. */
|
|
|
|
dev_t i_dev; /* which device is the inode on */
|
|
|
|
ino_t i_num; /* inode number on its (minor) device */
|
|
|
|
int i_count; /* # times inode used; 0 means slot is free */
|
2010-06-01 14:35:33 +02:00
|
|
|
unsigned int i_ndzones; /* # direct zones (Vx_NR_DZONES) */
|
|
|
|
unsigned int i_nindirs; /* # indirect zones per indirect block */
|
2005-04-21 16:53:53 +02:00
|
|
|
struct super_block *i_sp; /* pointer to super block for inode's device */
|
|
|
|
char i_dirt; /* CLEAN or DIRTY */
|
2010-06-01 14:35:33 +02:00
|
|
|
zone_t i_zsearch; /* where to start search for new zones */
|
2011-08-11 17:12:07 +02:00
|
|
|
off_t i_last_dpos; /* where to start dentry search */
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2007-08-07 14:38:35 +02:00
|
|
|
char i_mountpoint; /* true if mounted on */
|
2006-10-25 15:40:36 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
char i_seek; /* set on LSEEK, cleared on READ/WRITE */
|
|
|
|
char i_update; /* the ATIME, CTIME, and MTIME bits are here */
|
2006-10-25 15:40:36 +02:00
|
|
|
|
|
|
|
LIST_ENTRY(inode) i_hash; /* hash list */
|
|
|
|
TAILQ_ENTRY(inode) i_unused; /* free and unused list */
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
} inode[NR_INODES];
|
|
|
|
|
2006-10-25 15:40:36 +02:00
|
|
|
/* list of unused/free inodes */
|
|
|
|
EXTERN TAILQ_HEAD(unused_inodes_t, inode) unused_inodes;
|
|
|
|
|
|
|
|
/* inode hashtable */
|
|
|
|
EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE];
|
|
|
|
|
|
|
|
EXTERN unsigned int inode_cache_hit;
|
|
|
|
EXTERN unsigned int inode_cache_miss;
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
/* Field values. Note that CLEAN and DIRTY are defined in "const.h" */
|
|
|
|
#define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */
|
|
|
|
#define ISEEK 1 /* i_seek = ISEEK if last op was SEEK */
|
2010-06-01 14:35:33 +02:00
|
|
|
|
2011-12-22 01:29:27 +01:00
|
|
|
#define IN_MARKCLEAN(i) i->i_dirt = IN_CLEAN
|
2011-12-22 01:29:27 +01:00
|
|
|
#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)
|
2011-12-22 01:29:27 +01:00
|
|
|
|
|
|
|
#define IN_ISCLEAN(i) i->i_dirt == IN_CLEAN
|
|
|
|
#define IN_ISDIRTY(i) i->i_dirt == IN_DIRTY
|
|
|
|
|
2010-06-01 14:35:33 +02:00
|
|
|
#endif
|