diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2007-03-12 12:16:52 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2007-03-12 12:16:52 +0000 |
commit | 771709eb7860077f6bd23db6583a6e4bffd7f756 (patch) | |
tree | bf90ea580c06ca59d01616d80a1764d6c48580d1 /sys/fs/pseudofs/pseudofs.c | |
parent | 763757b2a462e98251200809dc4a89b4a6980602 (diff) | |
download | src-771709eb7860077f6bd23db6583a6e4bffd7f756.tar.gz src-771709eb7860077f6bd23db6583a6e4bffd7f756.zip |
Add a pn_destroy field to pfs_node. This field points to a destructor
function which is called from pfs_destroy() before the node is reclaimed.
Modify pfs_create_{dir,file,link}() to accept a pointer to a destructor
function in addition to the usual attr / fill / vis pointers.
This breaks both the programming and binary interfaces between pseudofs
and its consumers. It is believed that there are no pseudofs consumers
outside the source tree, so that the impact of this change is minimal.
Submitted by: Aniruddha Bohra <bohra@cs.rutgers.edu>
Notes
Notes:
svn path=/head/; revision=167482
Diffstat (limited to 'sys/fs/pseudofs/pseudofs.c')
-rw-r--r-- | sys/fs/pseudofs/pseudofs.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index da1758b9303e..42c45bbd4908 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -122,7 +122,8 @@ _pfs_fixup_dir(struct pfs_node *parent) */ struct pfs_node * pfs_create_dir(struct pfs_node *parent, const char *name, - pfs_attr_t attr, pfs_vis_t vis, int flags) + pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, + int flags) { struct pfs_node *dir; @@ -135,6 +136,7 @@ pfs_create_dir(struct pfs_node *parent, const char *name, dir->pn_type = (flags & PFS_PROCDEP) ? pfstype_procdir : pfstype_dir; dir->pn_attr = attr; dir->pn_vis = vis; + dir->pn_destroy = destroy; dir->pn_flags = flags; if (_pfs_add_node(parent, dir) != 0) { @@ -155,7 +157,8 @@ pfs_create_dir(struct pfs_node *parent, const char *name, */ struct pfs_node * pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, int flags) + pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, + int flags) { struct pfs_node *node; @@ -169,6 +172,7 @@ pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill, node->pn_func = fill; node->pn_attr = attr; node->pn_vis = vis; + node->pn_destroy = destroy; node->pn_flags = flags; if (_pfs_add_node(parent, node) != 0) { @@ -184,11 +188,12 @@ pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill, */ struct pfs_node * pfs_create_link(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, int flags) + pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, + int flags) { struct pfs_node *node; - node = pfs_create_file(parent, name, fill, attr, vis, flags); + node = pfs_create_file(parent, name, fill, attr, vis, destroy, flags); if (node == NULL) return (NULL); node->pn_type = pfstype_symlink; @@ -249,6 +254,10 @@ pfs_destroy(struct pfs_node *node) mtx_unlock(&node->pn_info->pi_mutex); } + /* callback to free any private resources */ + if(node->pn_destroy != NULL) + (node->pn_destroy)(node); + /* revoke vnodes and release memory */ pfs_disable(node); FREE(node, M_PFSNODES); |