46 |
46 |
47 #define VFS_DIR VFSDir* |
47 #define VFS_DIR VFSDir* |
48 #define VFS_ENTRY VFSEntry |
48 #define VFS_ENTRY VFSEntry |
49 |
49 |
50 struct VFS { |
50 struct VFS { |
51 SYS_FILE (*open)(VFSContext *ctx, char *path, int oflags); |
51 SYS_FILE (*open)(VFSContext *ctx, const char *path, int oflags); |
52 int (*stat)(VFSContext *ctx, char *path, struct stat *buf); |
52 int (*stat)(VFSContext *ctx, const char *path, struct stat *buf); |
53 int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
53 int (*fstat)(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
54 VFS_DIR (*opendir)(VFSContext *ctx, char *path); |
54 VFS_DIR (*opendir)(VFSContext *ctx, const char *path); |
55 int (*mkdir)(VFSContext *ctx, char *path); |
55 VFS_DIR (*fdopendir)(VFSContext *ctx, SYS_FILE fd); |
56 int (*unlink)(VFSContext *ctx, char *path); |
56 int (*mkdir)(VFSContext *ctx, const char *path); |
|
57 int (*unlink)(VFSContext *ctx, const char *path); |
|
58 int (*rmdir)(VFSContext *Ctx, const char *path); |
57 uint32_t flags; |
59 uint32_t flags; |
|
60 void *instance; |
58 }; |
61 }; |
59 |
62 |
60 struct VFSContext { |
63 struct VFSContext { |
61 pool_handle_t *pool; |
64 pool_handle_t *pool; |
62 Session *sn; |
65 Session *sn; |
96 ssize_t (*pwrite)(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset); |
100 ssize_t (*pwrite)(SYS_FILE fd, const void *buf, size_t nbyte, off_t offset); |
97 off_t (*seek)(SYS_FILE fd, off_t offset, int whence); |
101 off_t (*seek)(SYS_FILE fd, off_t offset, int whence); |
98 void (*close)(SYS_FILE fd); |
102 void (*close)(SYS_FILE fd); |
99 int (*opt_aioread)(aiocb_s *aiocb); |
103 int (*opt_aioread)(aiocb_s *aiocb); |
100 int (*opt_aiowrite)(aiocb_s *aiocb); |
104 int (*opt_aiowrite)(aiocb_s *aiocb); |
|
105 const char* (*opt_getetag)(SYS_FILE fd); |
101 }; |
106 }; |
102 |
107 |
103 struct VFS_DIRIO { |
108 struct VFS_DIRIO { |
104 int (*readdir)(VFS_DIR dir, VFS_ENTRY *entry, int getstat); |
109 int (*readdir)(VFS_DIR dir, VFS_ENTRY *entry, int getstat); |
105 void (*close)(VFS_DIR dir); |
110 void (*close)(VFS_DIR dir); |
106 }; |
111 }; |
107 |
112 |
|
113 typedef void*(*vfs_init_func)(ServerConfiguration *cfg, pool_handle_t *pool, WSConfigNode *config); |
|
114 typedef VFS*(*vfs_create_func)(Session *sn, Request *rq, pblock *pb, void *initData); |
|
115 |
108 /* |
116 /* |
109 * registers a new VFS |
117 * registers a new VFS |
110 */ |
118 */ |
111 void vfs_add(char *name, VFS *vfs); |
119 int vfs_register_type(const char *name, vfs_init_func vfsInit, vfs_create_func vfsCreate); |
|
120 |
|
121 /* |
|
122 * Create a new VFS instance |
|
123 */ |
|
124 VFS* vfs_create(Session *sn, Request *rq, const char *vfs_class, pblock *pb, void *initData); |
112 |
125 |
113 /* |
126 /* |
114 * creates a VFSContext for a Request |
127 * creates a VFSContext for a Request |
115 * vfs calls will do ACL checks |
128 * vfs calls will do ACL checks |
116 */ |
129 */ |
117 VFSContext* vfs_request_context(Session *sn, Request *rq); |
130 VFSContext* vfs_request_context(Session *sn, Request *rq); |
118 |
131 |
119 SYS_FILE vfs_open(VFSContext *ctx, char *path, int oflags); |
132 SYS_FILE vfs_open(VFSContext *ctx, const char *path, int oflags); |
120 SYS_FILE vfs_openRO(VFSContext *ctx, char *path); |
133 SYS_FILE vfs_openRO(VFSContext *ctx, const char *path); |
121 SYS_FILE vfs_openWO(VFSContext *ctx, char *path); |
134 SYS_FILE vfs_openWO(VFSContext *ctx, const char *path); |
122 SYS_FILE vfs_openRW(VFSContext *ctx, char *path); |
135 SYS_FILE vfs_openRW(VFSContext *ctx, const char *path); |
123 int vfs_stat(VFSContext *ctx, char *path, struct stat *buf); |
136 int vfs_stat(VFSContext *ctx, const char *path, struct stat *buf); |
124 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
137 int vfs_fstat(VFSContext *ctx, SYS_FILE fd, struct stat *buf); |
|
138 const char * vfs_getetag(SYS_FILE fd); |
125 void vfs_close(SYS_FILE fd); |
139 void vfs_close(SYS_FILE fd); |
126 VFS_DIR vfs_opendir(VFSContext *ctx, char *path); |
140 VFS_DIR vfs_opendir(VFSContext *ctx, const char *path); |
|
141 VFS_DIR vfs_fdopendir(VFSContext *ctx, SYS_FILE fd); |
127 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); |
142 int vfs_readdir(VFS_DIR dir, VFS_ENTRY *entry); |
128 int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); |
143 int vfs_readdir_stat(VFS_DIR dir, VFS_ENTRY *entry); |
129 void vfs_closedir(VFS_DIR dir); |
144 void vfs_closedir(VFS_DIR dir); |
130 int vfs_mkdir(VFSContext *ctx, char *path); |
145 int vfs_mkdir(VFSContext *ctx, const char *path); |
131 int vfs_unlink(VFSContext *ctx, char *path); |
146 int vfs_unlink(VFSContext *ctx, const char *path); |
|
147 int vfs_rmdir(VFSContext *ctx, const char *path); |
132 |
148 |
133 #ifdef __cplusplus |
149 #ifdef __cplusplus |
134 } |
150 } |
135 #endif |
151 #endif |
136 |
152 |