1433d6423SLionel Sambuc #ifndef _VTREEFS_INODE_H 2433d6423SLionel Sambuc #define _VTREEFS_INODE_H 3433d6423SLionel Sambuc 4693ad767SDavid van Moolenbroek /* 5*129adfebSDavid van Moolenbroek * Callback data can be a pointer or a (cast) integer value. For now, we 6*129adfebSDavid van Moolenbroek * instruct the state transfer framework that it should translate only 7*129adfebSDavid van Moolenbroek * recognized pointers. 8*129adfebSDavid van Moolenbroek */ 9*129adfebSDavid van Moolenbroek typedef cbdata_t cixfer_cbdata_t; 10*129adfebSDavid van Moolenbroek 11*129adfebSDavid van Moolenbroek /* 12693ad767SDavid van Moolenbroek * The inodes that are active, form a fully connected tree. Each node except 13433d6423SLionel Sambuc * the root node has a parent and a tail queue of children, where each child 14433d6423SLionel Sambuc * inode points to the "next" and "previous" inode with a common parent. 15433d6423SLionel Sambuc * 16433d6423SLionel Sambuc * Each inode that has a parent (i.e. active and not the root), is part of a 17433d6423SLionel Sambuc * <parent,name> -> inode hashtable, and if it has an index into the parent, 18433d6423SLionel Sambuc * is part of a <parent,index> -> inode hashtable. 19433d6423SLionel Sambuc * 20433d6423SLionel Sambuc * Inodes that are not active, are either deleted or free. A deleted inode is 21433d6423SLionel Sambuc * in use as long as it still has a nonzero reference count, even though it is 22433d6423SLionel Sambuc * no longer part of the tree. Inodes that are free, are part of the list of 23433d6423SLionel Sambuc * unused inodes. 24433d6423SLionel Sambuc */ 25433d6423SLionel Sambuc struct inode { 2652be5c0aSDavid van Moolenbroek /* Inode identity */ 2752be5c0aSDavid van Moolenbroek unsigned int i_num; /* index number into the inode array */ 2852be5c0aSDavid van Moolenbroek /* Note that the actual inode number (of type ino_t) is (i_num + 1). */ 2952be5c0aSDavid van Moolenbroek 30433d6423SLionel Sambuc /* Inode metadata */ 31433d6423SLionel Sambuc struct inode_stat i_stat; /* POSIX attributes */ 32c21aa858SCristiano Giuffrida char i_namebuf[PNAME_MAX + 1]; /* buffer for static (short) names */ 33c21aa858SCristiano Giuffrida char *i_name; /* name of the inode in the parent */ 340dc5c83eSDavid van Moolenbroek unsigned int i_count; /* reference count */ 35433d6423SLionel Sambuc index_t i_index; /* index number in parent / NO_INDEX */ 36433d6423SLionel Sambuc int i_indexed; /* number of indexed entries */ 37*129adfebSDavid van Moolenbroek cixfer_cbdata_t i_cbdata; /* callback data */ 38433d6423SLionel Sambuc unsigned short i_flags; /* I_DELETED or 0 */ 39433d6423SLionel Sambuc 40433d6423SLionel Sambuc /* Tree structure */ 41433d6423SLionel Sambuc struct inode *i_parent; /* parent of the node */ 42433d6423SLionel Sambuc TAILQ_ENTRY(inode) i_siblings; /* hash list for parent's children */ 43433d6423SLionel Sambuc TAILQ_HEAD(i_child, inode) i_children; /* parent's children */ 44433d6423SLionel Sambuc 45433d6423SLionel Sambuc /* Hash/free structure */ 46433d6423SLionel Sambuc LIST_ENTRY(inode) i_hname; /* hash list for name hash table */ 47433d6423SLionel Sambuc LIST_ENTRY(inode) i_hindex; /* hash list for index hash table */ 48433d6423SLionel Sambuc TAILQ_ENTRY(inode) i_unused; /* list of unused nodes */ 49433d6423SLionel Sambuc }; 50433d6423SLionel Sambuc 51433d6423SLionel Sambuc #define I_DELETED 0x1 /* the inode is scheduled for deletion */ 52433d6423SLionel Sambuc 53433d6423SLionel Sambuc #endif /* _VTREEFS_INODE_H */ 54