packvfs
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/vnode.h Fri Aug 02 06:03:38 2013 +0300 1.3 @@ -0,0 +1,46 @@ 1.4 +#ifndef VNODE_H_ 1.5 +#define VNODE_H_ 1.6 + 1.7 +#include "pvfs_impl.h" 1.8 + 1.9 +enum node_type { 1.10 + VNODE_FILE, 1.11 + VNODE_DIR 1.12 +}; 1.13 + 1.14 +struct vnode { 1.15 + char *name; 1.16 + enum node_type type; 1.17 + /* obj is PVFS_FILE* or PVFS_DIR* depending on type. 1.18 + * use VFILE/VDIR macros to access. 1.19 + */ 1.20 + void *obj; 1.21 + 1.22 + /* this is a link to some other vnode which is mounted in this place */ 1.23 + struct vnode *target; 1.24 + 1.25 + /* regular tree stuff */ 1.26 + struct vnode *parent; 1.27 + struct vnode *childlist; 1.28 + struct vnode *next; 1.29 +}; 1.30 + 1.31 +#define VFILE(n) \ 1.32 + (assert((n)->type == VNODE_FILE), (PVFS_FILE*)(n)->obj) 1.33 +#define VDIR(n) \ 1.34 + (assert((n)->type == VNODE_DIR), (PVFS_DIR*)(n)->obj) 1.35 + 1.36 +struct vnode *vnode_create(const char *name); 1.37 +struct vnode *vnode_create_file(const char *name, PVFS_FILE *fp); 1.38 +struct vnode *vnode_create_dir(const char *name, PVFS_DIR *dir); 1.39 +void vnode_free(struct vnode *n); 1.40 +void vnode_destroy_tree(struct vnode *tree); 1.41 + 1.42 +struct vnode *vnode_lookup(const char *path); 1.43 +#define vnode_getcwd() vnode_lookup("") 1.44 +#define vnode_getroot() vnode_lookup("/") 1.45 + 1.46 +int vnode_chdir(const char *name); 1.47 +int vnode_mkdir(struct vnode *parent, const char *name); 1.48 + 1.49 +#endif /* VNODE_H_ */