packvfs

view src/vnode.h @ 2:dc23ab0545a6

- fleshed out some more fucntions with the code for the case where file/dir are real - added install/uninstall targets to the makefile - added pvfsh (packvfs shell) test program
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 04 Nov 2013 03:50:55 +0200
parents
children
line source
1 #ifndef VNODE_H_
2 #define VNODE_H_
4 #include "pvfs_impl.h"
6 enum node_type {
7 VNODE_FILE,
8 VNODE_DIR
9 };
11 struct vnode {
12 char *name;
13 enum node_type type;
14 /* obj is PVFS_FILE* or PVFS_DIR* depending on type.
15 * use VFILE/VDIR macros to access.
16 */
17 void *obj;
19 /* this is a link to some other vnode which is mounted in this place */
20 struct vnode *target;
22 /* regular tree stuff */
23 struct vnode *parent;
24 struct vnode *childlist;
25 struct vnode *next;
26 };
28 #define VFILE(n) \
29 (assert((n)->type == VNODE_FILE), (PVFS_FILE*)(n)->obj)
30 #define VDIR(n) \
31 (assert((n)->type == VNODE_DIR), (PVFS_DIR*)(n)->obj)
33 struct vnode *vnode_create(const char *name);
34 struct vnode *vnode_create_file(const char *name, PVFS_FILE *fp);
35 struct vnode *vnode_create_dir(const char *name, PVFS_DIR *dir);
36 void vnode_free(struct vnode *n);
37 void vnode_destroy_tree(struct vnode *tree);
39 struct vnode *vnode_lookup(const char *path);
40 #define vnode_getcwd() vnode_lookup("")
41 #define vnode_getroot() vnode_lookup("/")
43 int vnode_chdir(const char *name);
44 int vnode_mkdir(struct vnode *parent, const char *name);
46 #endif /* VNODE_H_ */