From e727a9a54d3505f911aee201cc3da0c545e7185a Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sat, 15 Feb 2020 15:11:35 +0100 Subject: [PATCH] added implementation of mountpoint --- cmake/unit_tests.cmake | 1 + cmake/webfuse_adapter.cmake | 1 + include/webfuse/adapter/mountpoint.h | 2 +- include/webfuse_adapter.h | 1 + lib/webfuse/adapter/api.c | 24 +++++++++++++++++++ lib/webfuse/adapter/impl/mountpoint.c | 34 +++++++++++++++++++++++++++ lib/webfuse/adapter/impl/mountpoint.h | 26 ++++++++++++++++++++ test/adapter/test_mountpoint.cc | 12 ++++++++++ 8 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 lib/webfuse/adapter/impl/mountpoint.c create mode 100644 lib/webfuse/adapter/impl/mountpoint.h create mode 100644 test/adapter/test_mountpoint.cc diff --git a/cmake/unit_tests.cmake b/cmake/unit_tests.cmake index 5af183a..b5ae7ad 100644 --- a/cmake/unit_tests.cmake +++ b/cmake/unit_tests.cmake @@ -26,6 +26,7 @@ add_executable(alltests test/adapter/test_credentials.cc test/adapter/test_authenticator.cc test/adapter/test_authenticators.cc + test/adapter/test_mountpoint.cc test/adapter/test_fuse_req.cc test/adapter/jsonrpc/test_util.cc test/adapter/jsonrpc/test_is_request.cc diff --git a/cmake/webfuse_adapter.cmake b/cmake/webfuse_adapter.cmake index 329a123..f970ef7 100644 --- a/cmake/webfuse_adapter.cmake +++ b/cmake/webfuse_adapter.cmake @@ -15,6 +15,7 @@ add_library(webfuse-adapter-static STATIC lib/webfuse/adapter/impl/authenticators.c lib/webfuse/adapter/impl/credentials.c lib/webfuse/adapter/impl/operations.c + lib/webfuse/adapter/impl/mountpoint.c lib/webfuse/adapter/impl/time/timepoint.c lib/webfuse/adapter/impl/time/timer.c lib/webfuse/adapter/impl/time/timeout_manager.c diff --git a/include/webfuse/adapter/mountpoint.h b/include/webfuse/adapter/mountpoint.h index 9b1d57f..0dba1cd 100644 --- a/include/webfuse/adapter/mountpoint.h +++ b/include/webfuse/adapter/mountpoint.h @@ -13,7 +13,7 @@ wf_mountpoint_create( char const * path); extern void -wf_mountpoint_release( +wf_mountpoint_dispose( struct wf_mountpoint * mountpoint); extern char const * diff --git a/include/webfuse_adapter.h b/include/webfuse_adapter.h index 8edad51..37c39c2 100644 --- a/include/webfuse_adapter.h +++ b/include/webfuse_adapter.h @@ -9,5 +9,6 @@ #include #include #include +#include #endif diff --git a/lib/webfuse/adapter/api.c b/lib/webfuse/adapter/api.c index af68a8e..370a55e 100644 --- a/lib/webfuse/adapter/api.c +++ b/lib/webfuse/adapter/api.c @@ -4,6 +4,7 @@ #include "webfuse/adapter/impl/server_protocol.h" #include "webfuse/adapter/impl/server_config.h" #include "webfuse/adapter/impl/credentials.h" +#include "webfuse/adapter/impl/mountpoint.h" // server @@ -134,3 +135,26 @@ char const * wf_credentials_get( { return wf_impl_credentials_get(credentials, key); } + +// mountpoint + +struct wf_mountpoint * +wf_mountpoint_create( + char const * path) +{ + return wf_impl_mountpoint_create(path); +} + +void +wf_mountpoint_dispose( + struct wf_mountpoint * mountpoint) +{ + wf_impl_mountpoint_dispose(mountpoint); +} + +char const * +wf_mountpoint_get_path( + struct wf_mountpoint const * mountpoint) +{ + return wf_impl_mountpoint_get_path(mountpoint); +} diff --git a/lib/webfuse/adapter/impl/mountpoint.c b/lib/webfuse/adapter/impl/mountpoint.c new file mode 100644 index 0000000..55535d6 --- /dev/null +++ b/lib/webfuse/adapter/impl/mountpoint.c @@ -0,0 +1,34 @@ +#include "webfuse/adapter/impl/mountpoint.h" + +#include +#include + +struct wf_mountpoint +{ + char * path; +}; + +struct wf_mountpoint * +wf_impl_mountpoint_create( + char const * path) +{ + struct wf_mountpoint * mountpoint = malloc(sizeof(struct wf_mountpoint)); + mountpoint->path = strdup(path); + + return mountpoint; +} + +void +wf_impl_mountpoint_dispose( + struct wf_mountpoint * mountpoint) +{ + free(mountpoint->path); + free(mountpoint); +} + +char const * +wf_impl_mountpoint_get_path( + struct wf_mountpoint const * mountpoint) +{ + return mountpoint->path; +} diff --git a/lib/webfuse/adapter/impl/mountpoint.h b/lib/webfuse/adapter/impl/mountpoint.h new file mode 100644 index 0000000..eb0145c --- /dev/null +++ b/lib/webfuse/adapter/impl/mountpoint.h @@ -0,0 +1,26 @@ +#ifndef WF_IMPL_MOUNTPOINT_H +#define WF_IMPL_MOUNTPOINT_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +extern struct wf_mountpoint * +wf_impl_mountpoint_create( + char const * path); + +extern void +wf_impl_mountpoint_dispose( + struct wf_mountpoint * mountpoint); + +extern char const * +wf_impl_mountpoint_get_path( + struct wf_mountpoint const * mountpoint); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/test/adapter/test_mountpoint.cc b/test/adapter/test_mountpoint.cc new file mode 100644 index 0000000..e21d176 --- /dev/null +++ b/test/adapter/test_mountpoint.cc @@ -0,0 +1,12 @@ +#include +#include "webfuse/adapter/mountpoint.h" + +TEST(mountpoint, get_path) +{ + wf_mountpoint * mountpoint = wf_mountpoint_create("/some/path"); + + ASSERT_NE(nullptr, mountpoint); + ASSERT_STREQ("/some/path", wf_mountpoint_get_path(mountpoint)); + + wf_mountpoint_dispose(mountpoint); +}