src/server/daemon/vfs.c

changeset 415
d938228c382e
parent 366
47bc686fafe4
child 450
d7b276de183b
equal deleted inserted replaced
414:99a34860c105 415:d938228c382e
31 #include <stdio.h> 31 #include <stdio.h>
32 #include <stdlib.h> 32 #include <stdlib.h>
33 #include <unistd.h> 33 #include <unistd.h>
34 #include <sys/types.h> 34 #include <sys/types.h>
35 #include <aio.h> 35 #include <aio.h>
36 #include <ucx/map.h> 36 #include <cx/hash_map.h>
37 37
38 #include "../util/pool.h" 38 #include "../util/pool.h"
39 #include "netsite.h" 39 #include "netsite.h"
40 #include "acl.h" 40 #include "acl.h"
41 #include "vfs.h" 41 #include "vfs.h"
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,
78 sys_dir_read, 78 sys_dir_read,
79 sys_dir_close 79 sys_dir_close
80 }; 80 };
81 81
82 int vfs_init(void) { 82 int vfs_init(void) {
83 vfs_type_map = ucx_map_new(16); 83 vfs_type_map = cxHashMapCreate(cxDefaultAllocator, 16);
84 if(!vfs_type_map) { 84 if(!vfs_type_map) {
85 return -1; 85 return -1;
86 } 86 }
87 return 0; 87 return 0;
88 } 88 }
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

mercurial