diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d8488..51b2d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ find_package(PkgConfig REQUIRED) pkg_check_modules(FUSE3 REQUIRED fuse3) pkg_check_modules(LWS REQUIRED libwebsockets) pkg_check_modules(JANSSON REQUIRED jansson) +pkg_check_modules(UUID REQUIRED uuid) add_definitions(-D_FILE_OFFSET_BITS=64) @@ -26,6 +27,7 @@ set(EXTRA_INCLUDE_DIRS ${FUSE3_INCLUDE_DIRS} ${LWS_INCLUDE_DIRS} ${JANSSON_INCLUDE_DIRS} + ${UUID_INCLUDE_DIRS} ) set(EXTRA_LIBS @@ -33,6 +35,7 @@ set(EXTRA_LIBS ${FUSE3_LIBRARIES} ${LWS_LIBRARIES} ${JANSSON_LIBRARIES} + ${UUID_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) @@ -41,6 +44,7 @@ set(EXTRA_CFLAGS ${FUSE3_CFLAGS_OTHER} ${LWS_CFLAGS_OTHER} ${JANSSON_CFLAGS_OTHER} + ${UUID_CFLAGS_OTHER} "-pthread" ) diff --git a/lib/webfuse/adapter/impl/session.c b/lib/webfuse/adapter/impl/session.c index 3a8be94..9f6bfd1 100644 --- a/lib/webfuse/adapter/impl/session.c +++ b/lib/webfuse/adapter/impl/session.c @@ -44,14 +44,14 @@ struct wf_impl_session * wf_impl_session_create( char const * protocol_name) { static int session_id = 0; - char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%d", mount_point, session_id); - session_id++; - mkdir(path, 0755); struct wf_impl_session * session = malloc(sizeof(struct wf_impl_session)); if (NULL != session) { + snprintf(session->mount_point, PATH_MAX, "%s/%d", mount_point, session_id); + session_id++; + mkdir(session->mount_point, 0755); + wf_dlist_item_init(&session->item); session->wsi = wsi; @@ -61,7 +61,7 @@ struct wf_impl_session * wf_impl_session_create( wf_impl_jsonrpc_proxy_init(&session->rpc, timeout_manager, &wf_impl_session_send, session); wf_message_queue_init(&session->queue); - bool success = wf_impl_filesystem_init(&session->filesystem, session, path); + bool success = wf_impl_filesystem_init(&session->filesystem, session, session->mount_point); if (success) { lws_sock_file_fd_type fd; @@ -76,6 +76,7 @@ struct wf_impl_session * wf_impl_session_create( if (!success) { + rmdir(session->mount_point); wf_impl_jsonrpc_proxy_cleanup(&session->rpc); wf_message_queue_cleanup(&session->queue); free(session); @@ -90,6 +91,7 @@ void wf_impl_session_dispose( struct wf_impl_session * session) { wf_impl_filesystem_cleanup(&session->filesystem); + rmdir(session->mount_point); wf_impl_jsonrpc_proxy_cleanup(&session->rpc); wf_message_queue_cleanup(&session->queue); diff --git a/lib/webfuse/adapter/impl/session.h b/lib/webfuse/adapter/impl/session.h index 3944f36..4fc8490 100644 --- a/lib/webfuse/adapter/impl/session.h +++ b/lib/webfuse/adapter/impl/session.h @@ -9,6 +9,8 @@ using std::size_t; #endif +#include + #include "webfuse/core/message_queue.h" #include "webfuse/adapter/impl/jsonrpc/proxy.h" #include "webfuse/adapter/impl/jsonrpc/server.h" @@ -29,6 +31,7 @@ struct wf_impl_timeout_manager; struct wf_impl_session { struct wf_dlist_item item; + char mount_point[PATH_MAX]; struct lws * wsi; struct lws * wsi_fuse; bool is_authenticated; diff --git a/lib/webfuse/core/container_of.h b/lib/webfuse/core/container_of.h index 6ddbb82..85afba6 100644 --- a/lib/webfuse/core/container_of.h +++ b/lib/webfuse/core/container_of.h @@ -9,8 +9,8 @@ #define WF_CONTAINER_OF(pointer, type, member) \ ({ \ - const typeof( ((type *)0)->member ) *__mptr = (pointer); \ - (type *)( (char *)__mptr - offsetof(type, member) ); \ + const typeof( ((type *)0)->member ) *__member = (pointer); \ + (type *)( (char *)__member - offsetof(type, member) ); \ }) #endif