Cristiano Giuffrida c21aa858e2 libvtreefs: dynamically allocate long inode names
Extended by David van Moolenbroek to continue using static buffers
for short inode names, so as to prevent important file system
services such as procfs from running out of memory at runtime.

Change-Id: I6f841741ee9944fc87dbdb78b5cdaa2abee9da76
2015-06-29 10:57:24 +00:00

47 lines
1.8 KiB
C

#ifndef _VTREEFS_INODE_H
#define _VTREEFS_INODE_H
/*
* The inodes that are active, form a fully connected tree. Each node except
* the root node has a parent and a tail queue of children, where each child
* inode points to the "next" and "previous" inode with a common parent.
*
* Each inode that has a parent (i.e. active and not the root), is part of a
* <parent,name> -> inode hashtable, and if it has an index into the parent,
* is part of a <parent,index> -> inode hashtable.
*
* Inodes that are not active, are either deleted or free. A deleted inode is
* in use as long as it still has a nonzero reference count, even though it is
* no longer part of the tree. Inodes that are free, are part of the list of
* unused inodes.
*/
struct inode {
/* Inode identity */
unsigned int i_num; /* index number into the inode array */
/* Note that the actual inode number (of type ino_t) is (i_num + 1). */
/* Inode metadata */
struct inode_stat i_stat; /* POSIX attributes */
char i_namebuf[PNAME_MAX + 1]; /* buffer for static (short) names */
char *i_name; /* name of the inode in the parent */
unsigned int i_count; /* reference count */
index_t i_index; /* index number in parent / NO_INDEX */
int i_indexed; /* number of indexed entries */
cbdata_t i_cbdata; /* callback data */
unsigned short i_flags; /* I_DELETED or 0 */
/* Tree structure */
struct inode *i_parent; /* parent of the node */
TAILQ_ENTRY(inode) i_siblings; /* hash list for parent's children */
TAILQ_HEAD(i_child, inode) i_children; /* parent's children */
/* Hash/free structure */
LIST_ENTRY(inode) i_hname; /* hash list for name hash table */
LIST_ENTRY(inode) i_hindex; /* hash list for index hash table */
TAILQ_ENTRY(inode) i_unused; /* list of unused nodes */
};
#define I_DELETED 0x1 /* the inode is scheduled for deletion */
#endif /* _VTREEFS_INODE_H */