xref: /minix3/minix/lib/libvtreefs/inode.h (revision 54841c01020c7c37459374422914e55290ba5e51)
1 #ifndef _VTREEFS_INODE_H
2 #define _VTREEFS_INODE_H
3 
4 /*
5  * The inodes that are active, form a fully connected tree.  Each node except
6  * the root node has a parent and a tail queue of children, where each child
7  * inode points to the "next" and "previous" inode with a common parent.
8  *
9  * Each inode that has a parent (i.e. active and not the root), is part of a
10  * <parent,name> -> inode hashtable, and if it has an index into the parent,
11  * is part of a <parent,index> -> inode hashtable.
12  *
13  * Inodes that are not active, are either deleted or free.  A deleted inode is
14  * in use as long as it still has a nonzero reference count, even though it is
15  * no longer part of the tree.  Inodes that are free, are part of the list of
16  * unused inodes.
17  */
18 struct inode {
19 	/* Inode identity */
20 	unsigned int i_num;		/* index number into the inode array */
21 	/* Note that the actual inode number (of type ino_t) is (i_num + 1). */
22 
23 	/* Inode metadata */
24 	struct inode_stat i_stat;	/* POSIX attributes */
25 	char i_name[PNAME_MAX + 1];	/* name of the inode in the parent */
26 	unsigned int i_count;		/* reference count */
27 	index_t i_index;		/* index number in parent / NO_INDEX */
28 	int i_indexed;			/* number of indexed entries */
29 	cbdata_t i_cbdata;		/* callback data */
30 	unsigned short i_flags;		/* I_DELETED or 0 */
31 
32 	/* Tree structure */
33 	struct inode *i_parent;		/* parent of the node */
34 	TAILQ_ENTRY(inode) i_siblings;	/* hash list for parent's children */
35 	TAILQ_HEAD(i_child, inode) i_children;	/* parent's children */
36 
37 	/* Hash/free structure */
38 	LIST_ENTRY(inode) i_hname;	/* hash list for name hash table */
39 	LIST_ENTRY(inode) i_hindex;	/* hash list for index hash table */
40 	TAILQ_ENTRY(inode) i_unused;	/* list of unused nodes */
41 };
42 
43 #define I_DELETED 	0x1	/* the inode is scheduled for deletion */
44 
45 #endif /* _VTREEFS_INODE_H */
46