1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

refactor: make filesystem independent of session

This commit is contained in:
Falk Werner
2020-06-12 22:53:42 +02:00
parent adaec875d9
commit 0c702ff25f
6 changed files with 16 additions and 24 deletions

View File

@@ -52,7 +52,8 @@ static void wf_impl_filesystem_cleanup(
static bool wf_impl_filesystem_init(
struct wf_impl_filesystem * filesystem,
struct wf_impl_session * session,
struct lws * session_wsi,
struct wf_jsonrpc_proxy * proxy,
char const * name,
struct wf_mountpoint * mountpoint)
{
@@ -63,7 +64,7 @@ static bool wf_impl_filesystem_init(
filesystem->args.argv = argv;
filesystem->args.allocated = 0;
filesystem->user_data.session = session;
filesystem->user_data.proxy = proxy;
filesystem->user_data.timeout = 1.0;
filesystem->user_data.name = strdup(name);
memset(&filesystem->buffer, 0, sizeof(struct fuse_buf));
@@ -85,8 +86,8 @@ static bool wf_impl_filesystem_init(
{
lws_sock_file_fd_type fd;
fd.filefd = fuse_session_fd(filesystem->session);
struct lws_protocols const * protocol = lws_get_protocol(session->wsi);
filesystem->wsi = lws_adopt_descriptor_vhost(lws_get_vhost(session->wsi), LWS_ADOPT_RAW_FILE_DESC, fd, protocol->name, session->wsi);
struct lws_protocols const * protocol = lws_get_protocol(session_wsi);
filesystem->wsi = lws_adopt_descriptor_vhost(lws_get_vhost(session_wsi), LWS_ADOPT_RAW_FILE_DESC, fd, protocol->name, session_wsi);
if (NULL == filesystem->wsi)
{
@@ -100,12 +101,13 @@ static bool wf_impl_filesystem_init(
}
struct wf_impl_filesystem * wf_impl_filesystem_create(
struct wf_impl_session * session,
struct lws * session_wsi,
struct wf_jsonrpc_proxy * proxy,
char const * name,
struct wf_mountpoint * mountpoint)
{
struct wf_impl_filesystem * filesystem = malloc(sizeof(struct wf_impl_filesystem));
bool success = wf_impl_filesystem_init(filesystem, session, name, mountpoint);
bool success = wf_impl_filesystem_init(filesystem, session_wsi, proxy, name, mountpoint);
if (!success)
{
free(filesystem);

View File

@@ -15,7 +15,7 @@ extern "C"
#endif
struct wf_mountpoint;
struct wf_impl_session;
struct wf_jsonrpc_proxy;
struct lws;
struct wf_impl_filesystem
@@ -30,7 +30,8 @@ struct wf_impl_filesystem
};
extern struct wf_impl_filesystem * wf_impl_filesystem_create(
struct wf_impl_session * session,
struct lws * session_wsi,
struct wf_jsonrpc_proxy * proxy,
char const * name,
struct wf_mountpoint * mountpoint);

View File

@@ -6,13 +6,5 @@
struct wf_jsonrpc_proxy * wf_impl_operation_context_get_proxy(
struct wf_impl_operation_context * context)
{
struct wf_jsonrpc_proxy * proxy = NULL;
struct wf_impl_session * session = context->session;
if (NULL != session)
{
proxy = session->rpc;
}
return proxy;
return context->proxy;
}

View File

@@ -7,12 +7,11 @@
extern "C" {
#endif
struct wf_impl_session;
struct wf_jsonrpc_proxy;
struct wf_impl_operation_context
{
struct wf_impl_session * session;
struct wf_jsonrpc_proxy * proxy;
double timeout;
char * name;
};

View File

@@ -108,7 +108,7 @@ bool wf_impl_session_add_filesystem(
if (result)
{
struct wf_impl_filesystem * filesystem = wf_impl_filesystem_create(session, name, mountpoint);
struct wf_impl_filesystem * filesystem = wf_impl_filesystem_create(session->wsi, session->rpc, name, mountpoint);
result = (NULL != filesystem);
if (result)
{