packvfs

view src/vnode.h @ 0:df5e9ee65a50

packvfs initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 02 Aug 2013 06:03:38 +0300
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_ */