mirror of
https://github.com/falk-werner/webfuse
synced 2025-06-13 12:54:15 +00:00
removes directory when session is closed
This commit is contained in:
parent
5a1101fee8
commit
7755ff2c63
@ -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"
|
||||
)
|
||||
|
||||
|
@ -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);
|
||||
|
@ -9,6 +9,8 @@
|
||||
using std::size_t;
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user