http://prdownloads.sourceforge.net/lufs/lufs-0.9.6.tar.gz?download
[lufs.git] / filesystems / wavfs / glue.cpp
1 /*
2  */
3
4 #include <fcntl.h>
5 #include <unistd.h>
6 #include <dirent.h>
7
8 #include <netinet/in.h>
9
10 #include <vector>
11 #include <string>
12
13 #include <lufs/proto.h>
14 #include <lufs/fs.h>
15
16 using namespace std;
17
18 #include "file_handle.h"
19 #include "fs_modules.h"
20 #include "handlefs.h"
21
22 extern "C"{
23
24 /********************************************************************************
25                                 C Wrappers
26 ********************************************************************************/
27         
28 void* wavfs_init(struct list_head *cfg, struct dir_cache *cache, struct credentials *cred, void **global_ctx)
29 {
30 /*    if(!lu_opt_getchar(cfg, "MOUNT", "username") || !lu_opt_getchar(cfg, "MOUNT", "host")){
31         ERROR("you must specify at least a host and an username!");
32         return NULL;
33     }
34  */  
35     return (void*)new HandleFS(cfg, cache, cred);
36 }
37
38 void wavfs_free(void *ctx)
39 {
40     HandleFS *p = (HandleFS*)ctx;
41     delete p;
42 }
43
44 int wavfs_mount(void *ctx)
45 {
46     return ((HandleFS*)ctx)->do_mount();
47 }
48
49 void wavfs_umount(void *ctx)
50 {
51         ((HandleFS*)ctx)->do_umount();
52 }
53
54 int wavfs_readdir(void *ctx, char *dir_name, struct directory *dir)
55 {
56     return ((HandleFS*)ctx)->do_readdir(dir_name, dir);
57 }
58
59 int wavfs_stat(void *ctx, char *name, struct lufs_fattr *fattr)
60 {
61     return ((HandleFS*)ctx)->do_stat(name, fattr);
62 }
63
64 int wavfs_open(void *ctx, char *file, unsigned mode)
65 {
66     return ((HandleFS*)ctx)->do_open(file);
67 }
68
69 int wavfs_release(void *ctx, char *file)
70 {
71     return ((HandleFS*)ctx)->do_release(file);
72 }
73
74 int wavfs_read(void *ctx, char *file, long long offset, unsigned long count, char *buf)
75 {
76     return ((HandleFS*)ctx)->do_read(file, offset, count, buf);
77 }
78
79 /********************************************************************************
80                                 Default OS Implementation
81 ********************************************************************************/
82
83 int wavfs_readlink(void *ctx, char *link, char *buf, int buflen)
84 {
85     return readlink(link, buf, buflen);
86 }
87
88 /********************************************************************************
89                                 Write operations are not implemented
90 ********************************************************************************/
91
92 int read_only_error()
93 {
94         ERROR("This filesystem is read-only.");
95         return -1;
96 }
97
98 int wavfs_mkdir(void *ctx, char *dir, int mode) { return read_only_error(); }
99 int wavfs_rmdir(void *ctx, char *dir)   { return read_only_error(); }
100 int wavfs_create(void *ctx, char *file, int mode)       { return read_only_error(); }
101 int wavfs_unlink(void *ctx, char *file) { return read_only_error(); }
102 int wavfs_rename(void *ctx, char *old_name, char *new_name)     { return read_only_error(); }
103 int wavfs_write(void *ctx, char *file, long long offset, unsigned long count, char *buf)        { return read_only_error(); }
104 int wavfs_link(void *ctx, char *target, char *link)     { return read_only_error(); }
105 int wavfs_symlink(void *ctx, char *target, char *link)  { return read_only_error(); }
106 int wavfs_setattr(void *ctx, char *file, struct lufs_fattr *fattr)      { return read_only_error(); }
107
108 } /* extern "C" */