[Libsysio-commit] HEAD: libsysio/include inode.h
Brought to you by:
lward
From: Lee W. <lw...@us...> - 2009-01-22 19:07:55
|
Update of /cvsroot/libsysio/libsysio/include In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15278/include Modified Files: inode.h Log Message: With I_ASSOCIATIONS defined, inodes keep a list of all path-base nodes that are currently associated. Always, association of a path-base node with an i-node is now done via the macro PB_SET_ASSOC(). This, new, macro will not allow an already associated path-base node to gain a new association; This to enforce the emerging policy of "once set, immutable" for these nodes. You can set the association of an unassociated path-base node or clear it, only. Index: inode.h =================================================================== RCS file: /cvsroot/libsysio/libsysio/include/inode.h,v retrieving revision 1.48 retrieving revision 1.49 diff -u -w -b -B -p -r1.48 -r1.49 --- inode.h 5 Jan 2009 19:19:29 -0000 1.48 +++ inode.h 22 Jan 2009 19:07:42 -0000 1.49 @@ -139,10 +139,22 @@ struct inode { struct inode_ops i_ops; /* operations */ struct intnl_stat i_stbuf; /* attrs */ struct filesys *i_fs; /* file system ptr */ +#ifdef I_ASSOCIATIONS + LIST_HEAD(, pnode_base) i_assoc; /* assoc'd pbnodes */ +#endif void *i_private; /* driver data */ TAILQ_ENTRY(inode) i_nodes; /* all i-nodes link */ }; +#ifdef I_ASSOCIATIONS +#define _I_INIT_MORE(_ino) \ + do { \ + LIST_INIT(&(_ino)->i_assoc); \ + } while (0) +#else +#define _I_INIT_MORE(_ino) +#endif + /* * Init an i-node record. */ @@ -160,6 +172,7 @@ struct inode { (ino)->i_stbuf = *(stat); \ (ino)->i_fs = (fs); \ (ino)->i_private = (private); \ + _I_INIT_MORE(ino); \ } while (0) #ifdef LOCK_DEBUG @@ -248,6 +261,20 @@ struct inode { } while (0) /* + * Check association; Logical true if so, otherwise false. + * + * NB: The given i-node should be locked or otherwise protected from + * manipulation by others. + */ +#ifdef I_ASSOCIATIONS +#define I_ISASSOC(_ino) \ + ((_ino)->i_assoc.lh_first) +#else +#define I_ISASSOC(_ino) \ + (0) +#endif + +/* * The "quick string" record (inspired by the structure of the same name * from Linux) is used to pass a string without delimiters as well as useful * information about the string. @@ -276,6 +303,9 @@ struct pnode_base { LIST_HEAD(, pnode_base) pb_children; /* children if a dir */ LIST_ENTRY(pnode_base) pb_sibs; /* links to siblings */ LIST_HEAD(, pnode) pb_aliases; /* aliases */ +#ifdef I_ASSOCIATIONS + LIST_ENTRY(pnode_base) pb_alinks; /* names to same ino */ +#endif #ifdef PB_DEBUG TAILQ_ENTRY(pnode_base) pb_links; /* leaf pbnodes links */ #endif @@ -284,7 +314,7 @@ struct pnode_base { /* * Init a path-base record. */ -#define PB_INIT(_pb, _name, _parent, _ino) \ +#define PB_INIT(_pb, _name, _parent) \ do { \ mutex_init(&(_pb)->pb_mutex, MUTEX_RECURSIVE); \ (_pb)->pb_lckcnt = 0; \ @@ -293,7 +323,7 @@ struct pnode_base { (_pb)->pb_tentry.tn_left = (_pb)->pb_tentry.tn_right = NULL; \ (_pb)->pb_key.pbk_name = *(_name); \ (_pb)->pb_key.pbk_parent = (_parent); \ - (_pb)->pb_ino = (_ino); \ + (_pb)->pb_ino = NULL; \ LIST_INIT(&(_pb)->pb_children); \ LIST_INIT(&(_pb)->pb_aliases); \ } while (0) @@ -342,6 +372,42 @@ struct pnode_base { } while (0) /* + * Set path-base node association. + * + * NB: All of the path-base node, any i-node it currently points at, and + * the new i-node must be locked. If the path-base node is associated, + * the association will be removed before making the new but it will not be + * released, unlocked, or dereferenced. + * + * NB(2): We no longer support re-association. Now, an association can be + * set, anew, or cleared (only when destroying the path-base node. + */ +#ifdef I_ASSOCIATIONS +#define PB_SET_ASSOC(_pb, _ino) \ + do { \ + _PB_CHECK_LOCK((_pb), 1); \ + if ((_pb)->pb_ino) { \ + assert(!(_ino)); \ + _I_CHECK_LOCK((_pb)->pb_ino, 1); \ + LIST_REMOVE((_pb), pb_alinks); \ + } \ + (_pb)->pb_ino = (_ino); \ + if ((_pb)->pb_ino) { \ + _I_CHECK_LOCK((_pb)->pb_ino, 1); \ + LIST_INSERT_HEAD(&(_pb)->pb_ino->i_assoc, \ + (_pb), \ + pb_alinks); \ + } \ + } while (0) +#else +#define PB_SET_ASSOC(_pb, _ino) \ + do { \ + assert(!((_pb)->pb_ino && (_ino))); \ + (_pb)->pb_ino = (_ino); \ + } while (0) +#endif + +/* * Since a file system may be multiply mounted, in different parts of the local * tree, a file system object may appear in different places. We handle that * with aliases. There is one pnode for every alias the system is tracking. |