src/server/daemon/vfs.c

branch
webdav
changeset 276
0cb4eda146c4
parent 269
3dfbd0b91950
child 277
7608af69739f
--- a/src/server/daemon/vfs.c	Thu Jan 27 21:24:27 2022 +0100
+++ b/src/server/daemon/vfs.c	Fri Jan 28 15:44:30 2022 +0100
@@ -45,7 +45,7 @@
 #define VFS_MALLOC(pool, size) pool ? pool_malloc(pool, size) : malloc(size)
 #define VFS_FREE(pool, ptr) pool ? pool_free(pool, ptr) : free(ptr)
 
-static UcxMap *vfs_map;
+static UcxMap *vfs_type_map;
 
 static VFS sys_vfs = {
     sys_vfs_open,
@@ -79,20 +79,22 @@
 };
 
 int vfs_init() {
-    vfs_map = ucx_map_new(16);
-    if(!vfs_map) {
+    vfs_type_map = ucx_map_new(16);
+    if(!vfs_type_map) {
         return -1;
     }
     return 0;
 }
 
-void vfs_add(char *name, VFS *vfs) {
+int vfs_register_type(const char *name, vfs_create_func vfsCreate) {
     WS_ASSERT(name);
     
-    if(!vfs_map) {
-        vfs_init();
+    if(!vfs_type_map) {
+        if(vfs_init()) {
+            return 1;
+        }
     }
-    ucx_map_cstr_put(vfs_map, name, vfs);
+    return ucx_map_cstr_put(vfs_type_map, name, vfsCreate);
 }
 
 VFSContext* vfs_request_context(Session *sn, Request *rq) {

mercurial