Constify, and add an API function to find a named node in a directory.

This commit is contained in:
des 2003-12-07 17:41:19 +00:00
parent 0864edfb36
commit ef7fbaac4f
2 changed files with 21 additions and 6 deletions

View File

@ -118,7 +118,7 @@ _pfs_fixup_dir(struct pfs_node *parent)
* Create a directory
*/
struct pfs_node *
pfs_create_dir(struct pfs_node *parent, char *name,
pfs_create_dir(struct pfs_node *parent, const char *name,
pfs_attr_t attr, pfs_vis_t vis, int flags)
{
struct pfs_node *dir;
@ -151,7 +151,7 @@ pfs_create_dir(struct pfs_node *parent, char *name,
* Create a file
*/
struct pfs_node *
pfs_create_file(struct pfs_node *parent, char *name, pfs_fill_t fill,
pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill,
pfs_attr_t attr, pfs_vis_t vis, int flags)
{
struct pfs_node *node;
@ -180,7 +180,7 @@ pfs_create_file(struct pfs_node *parent, char *name, pfs_fill_t fill,
* Create a symlink
*/
struct pfs_node *
pfs_create_link(struct pfs_node *parent, char *name, pfs_fill_t fill,
pfs_create_link(struct pfs_node *parent, const char *name, pfs_fill_t fill,
pfs_attr_t attr, pfs_vis_t vis, int flags)
{
struct pfs_node *node;
@ -192,6 +192,20 @@ pfs_create_link(struct pfs_node *parent, char *name, pfs_fill_t fill,
return (node);
}
/*
* Locate a node by name
*/
struct pfs_node *
pfs_find_node(struct pfs_node *parent, const char *name)
{
struct pfs_node *node;
for (node = parent->pn_nodes; node != NULL; node = node->pn_next)
if (strcmp(node->pn_name, name) == 0)
return (node);
return (NULL);
}
/*
* Destroy a node or a tree of nodes
*/

View File

@ -210,14 +210,15 @@ int pfs_uninit (struct pfs_info *pi, struct vfsconf *vfc);
/*
* Directory structure construction and manipulation
*/
struct pfs_node *pfs_create_dir (struct pfs_node *parent, char *name,
struct pfs_node *pfs_create_dir (struct pfs_node *parent, const char *name,
pfs_attr_t attr, pfs_vis_t vis, int flags);
struct pfs_node *pfs_create_file(struct pfs_node *parent, 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);
struct pfs_node *pfs_create_link(struct pfs_node *parent, char *name,
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);
struct pfs_node *pfs_find_node (struct pfs_node *parent, const char *name);
int pfs_disable (struct pfs_node *pn);
int pfs_enable (struct pfs_node *pn);
int pfs_destroy (struct pfs_node *pn);