diff options
author | des <des@FreeBSD.org> | 2003-12-07 17:41:19 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2003-12-07 17:41:19 +0000 |
commit | ef7fbaac4f9ae990852d6dbbd8dffeec674c4102 (patch) | |
tree | 732ed309c28c1fb98dccdf480b2c252f844ee9c0 /sys/fs | |
parent | 0864edfb363abcb91a441a52e655e2bfbd843979 (diff) | |
download | FreeBSD-src-ef7fbaac4f9ae990852d6dbbd8dffeec674c4102.zip FreeBSD-src-ef7fbaac4f9ae990852d6dbbd8dffeec674c4102.tar.gz |
Constify, and add an API function to find a named node in a directory.
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/pseudofs/pseudofs.c | 20 | ||||
-rw-r--r-- | sys/fs/pseudofs/pseudofs.h | 7 |
2 files changed, 21 insertions, 6 deletions
diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index 8297ef6..4db02b4 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -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; @@ -193,6 +193,20 @@ pfs_create_link(struct pfs_node *parent, char *name, pfs_fill_t fill, } /* + * 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 */ int diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h index 021ea3f..2d44811 100644 --- a/sys/fs/pseudofs/pseudofs.h +++ b/sys/fs/pseudofs/pseudofs.h @@ -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); |