43 #include "event.h" |
43 #include "event.h" |
44 |
44 |
45 #define VFS_MALLOC(pool, size) pool ? pool_malloc(pool, size) : malloc(size) |
45 #define VFS_MALLOC(pool, size) pool ? pool_malloc(pool, size) : malloc(size) |
46 #define VFS_FREE(pool, ptr) pool ? pool_free(pool, ptr) : free(ptr) |
46 #define VFS_FREE(pool, ptr) pool ? pool_free(pool, ptr) : free(ptr) |
47 |
47 |
48 static UcxMap *vfs_type_map; |
48 static CxMap *vfs_type_map; |
49 |
49 |
50 static VFS sys_vfs = { |
50 static VFS sys_vfs = { |
51 sys_vfs_open, |
51 sys_vfs_open, |
52 sys_vfs_stat, |
52 sys_vfs_stat, |
53 sys_vfs_fstat, |
53 sys_vfs_fstat, |
101 return 1; |
101 return 1; |
102 } |
102 } |
103 vfsType->init = vfsInit; |
103 vfsType->init = vfsInit; |
104 vfsType->create = vfsCreate; |
104 vfsType->create = vfsCreate; |
105 |
105 |
106 return ucx_map_cstr_put(vfs_type_map, name, vfsType); |
106 return cxMapPut(vfs_type_map, cx_hash_key_str(name), vfsType); |
107 } |
107 } |
108 |
108 |
109 VfsType* vfs_get_type(scstr_t vfs_class) { |
109 VfsType* vfs_get_type(cxstring vfs_class) { |
110 return ucx_map_sstr_get(vfs_type_map, vfs_class); |
110 return cxMapGet(vfs_type_map, cx_hash_key_bytes((const unsigned char*)vfs_class.ptr, vfs_class.length)); |
111 } |
111 } |
112 |
112 |
113 void* vfs_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, VfsType *vfs_class, WSConfigNode *config, int *error) { |
113 void* vfs_init_backend(ServerConfiguration *cfg, pool_handle_t *pool, VfsType *vfs_class, WSConfigNode *config, int *error) { |
114 *error = 0; |
114 *error = 0; |
115 if(vfs_class->init) { |
115 if(vfs_class->init) { |
122 return NULL; |
122 return NULL; |
123 } |
123 } |
124 } |
124 } |
125 |
125 |
126 VFS* vfs_create(Session *sn, Request *rq, const char *vfs_class, pblock *pb, void *initData) { |
126 VFS* vfs_create(Session *sn, Request *rq, const char *vfs_class, pblock *pb, void *initData) { |
127 VfsType *vfsType = ucx_map_cstr_get(vfs_type_map, vfs_class); |
127 VfsType *vfsType = cxMapGet(vfs_type_map, cx_hash_key_str(vfs_class)); |
128 if(!vfsType) { |
128 if(!vfsType) { |
129 log_ereport(LOG_MISCONFIG, "vfs_create: unkown VFS type %s", vfs_class); |
129 log_ereport(LOG_MISCONFIG, "vfs_create: unkown VFS type %s", vfs_class); |
130 return NULL; |
130 return NULL; |
131 } |
131 } |
132 |
132 |