From 17fa84bc3871eec23edfcc1bcf2be15489499180 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Thu, 20 Feb 2020 18:54:29 +0100 Subject: [PATCH] made static_filesystem private (used for test purposes only) --- cmake/unit_tests.cmake | 4 +- cmake/webfuse_core.cmake | 1 - cmake/webfuse_provider.cmake | 1 - include/webfuse/provider/static_filesystem.h | 114 ------------------ include/webfuse_provider.h | 2 - lib/webfuse/provider/api.c | 58 --------- lib/webfuse/provider/impl/static_filesystem.h | 52 -------- test/webfuse/tests/core/test_path.cc | 58 --------- test/webfuse/tests/integration/provider.cc | 1 + .../tests/provider/test_static_filesystem.cc | 61 ---------- .../core => test/webfuse/utils}/path.c | 2 +- .../core => test/webfuse/utils}/path.h | 0 .../webfuse/utils}/static_filesystem.c | 104 ++++++++-------- test/webfuse/utils/static_filesystem.h | 77 ++++++++++++ 14 files changed, 133 insertions(+), 402 deletions(-) delete mode 100644 include/webfuse/provider/static_filesystem.h delete mode 100644 lib/webfuse/provider/impl/static_filesystem.h delete mode 100644 test/webfuse/tests/core/test_path.cc delete mode 100644 test/webfuse/tests/provider/test_static_filesystem.cc rename {lib/webfuse/core => test/webfuse/utils}/path.c (98%) rename {lib/webfuse/core => test/webfuse/utils}/path.h (100%) rename {lib/webfuse/provider/impl => test/webfuse/utils}/static_filesystem.c (75%) create mode 100644 test/webfuse/utils/static_filesystem.h diff --git a/cmake/unit_tests.cmake b/cmake/unit_tests.cmake index 14ff04d..dfc804e 100644 --- a/cmake/unit_tests.cmake +++ b/cmake/unit_tests.cmake @@ -12,13 +12,14 @@ add_executable(alltests test/webfuse/utils/msleep.cc test/webfuse/utils/die_if.cc test/webfuse/utils/timeout_watcher.cc + test/webfuse/utils/path.c + test/webfuse/utils/static_filesystem.c test/webfuse/fakes/fake_adapter_server.cc test/webfuse/mocks/mock_authenticator.cc test/webfuse/mocks/mock_request.cc test/webfuse/tests/core/test_container_of.cc test/webfuse/tests/core/test_string.cc test/webfuse/tests/core/test_slist.cc - test/webfuse/tests/core/test_path.cc test/webfuse/tests/core/test_base64.cc test/webfuse/tests/core/test_status.cc test/webfuse/tests/core/test_message.cc @@ -43,7 +44,6 @@ add_executable(alltests test/webfuse/tests/adapter/jsonrpc/test_server.cc test/webfuse/tests/adapter/jsonrpc/test_proxy.cc test/webfuse/tests/provider/test_url.cc - test/webfuse/tests/provider/test_static_filesystem.cc test/webfuse/tests/provider/test_client_protocol.cc test/webfuse/tests/integration/test_integration.cc test/webfuse/tests/integration/server.cc diff --git a/cmake/webfuse_core.cmake b/cmake/webfuse_core.cmake index b162f40..52c7681 100644 --- a/cmake/webfuse_core.cmake +++ b/cmake/webfuse_core.cmake @@ -6,7 +6,6 @@ add_library(webfuse-core STATIC lib/webfuse/core/message_queue.c lib/webfuse/core/status.c lib/webfuse/core/string.c - lib/webfuse/core/path.c lib/webfuse/core/base64.c lib/webfuse/core/lws_log.c ) diff --git a/cmake/webfuse_provider.cmake b/cmake/webfuse_provider.cmake index b42f1f4..5079cb1 100644 --- a/cmake/webfuse_provider.cmake +++ b/cmake/webfuse_provider.cmake @@ -15,7 +15,6 @@ add_library(webfuse-provider-static STATIC lib/webfuse/provider/impl/operation/open.c lib/webfuse/provider/impl/operation/close.c lib/webfuse/provider/impl/operation/read.c - lib/webfuse/provider/impl/static_filesystem.c ) set_target_properties(webfuse-provider-static PROPERTIES OUTPUT_NAME webfuse-provider) diff --git a/include/webfuse/provider/static_filesystem.h b/include/webfuse/provider/static_filesystem.h deleted file mode 100644 index e736976..0000000 --- a/include/webfuse/provider/static_filesystem.h +++ /dev/null @@ -1,114 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file provider/static_filesystem.h -/// \brief Reference implementation of static filesystem. -/// -/// This header is used by integration tests. It may be removed from the -/// library. -/// -/// \todo Remove this header from library -//////////////////////////////////////////////////////////////////////////////// - -#ifndef WFP_STATIC_FILESYSTEM_H -#define WFP_STATIC_FILESYSTEM_H - -#ifndef __cplusplus -#include -#else -#include -using ::std::size_t; -#endif - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - -struct wfp_client_config; - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -struct wfp_static_filesystem; - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -typedef size_t -wfp_static_filesystem_read_fn( - size_t offset, - char * buffer, - size_t buffer_size, - void * user_data); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -typedef void -wfp_static_filesystem_get_info_fn( - void * user_data, - int * result_mode, - size_t * result_size); - - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API struct wfp_static_filesystem * -wfp_static_filesystem_create( - struct wfp_client_config * config); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API void -wfp_static_filesystem_dispose( - struct wfp_static_filesystem * filesystem); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API void -wfp_static_filesystem_add( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content, - size_t length); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API void -wfp_static_filesystem_add_text( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API void -wfp_static_filesystem_add_file( - struct wfp_static_filesystem * filesystem, - char const * path, - char const * filename); - -//------------------------------------------------------------------------------ -/// \deprecated This will be removed. Dont use it. -//------------------------------------------------------------------------------ -extern WFP_API void -wfp_static_filesystem_add_generic( - struct wfp_static_filesystem * filesystem, - char const * path, - wfp_static_filesystem_read_fn * read, - wfp_static_filesystem_get_info_fn * get_info, - void * user_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/webfuse_provider.h b/include/webfuse_provider.h index 5882c60..bd119ac 100644 --- a/include/webfuse_provider.h +++ b/include/webfuse_provider.h @@ -22,6 +22,4 @@ #include #include -#include - #endif diff --git a/lib/webfuse/provider/api.c b/lib/webfuse/provider/api.c index 933516b..0c0e88a 100644 --- a/lib/webfuse/provider/api.c +++ b/lib/webfuse/provider/api.c @@ -11,7 +11,6 @@ #include "webfuse/provider/impl/client_config.h" #include "webfuse/provider/impl/client.h" #include "webfuse/provider/impl/dirbuffer.h" -#include "webfuse/provider/impl/static_filesystem.h" // respond @@ -241,60 +240,3 @@ void wfp_dirbuffer_add( { wfp_impl_dirbuffer_add(buffer, name, inode); } - -// static_filesystem - -struct wfp_static_filesystem * -wfp_static_filesystem_create( - struct wfp_client_config * config) -{ - return wfp_impl_static_filesystem_create(config); -} - -void -wfp_static_filesystem_dispose( - struct wfp_static_filesystem * filesystem) -{ - wfp_impl_static_filesystem_dispose(filesystem); -} - -void -wfp_static_filesystem_add( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content, - size_t length) -{ - wfp_impl_static_filesystem_add(filesystem, path, mode, content, length); -} - -void -wfp_static_filesystem_add_text( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content) -{ - wfp_impl_static_filesystem_add_text(filesystem, path, mode, content); -} - -void -wfp_static_filesystem_add_file( - struct wfp_static_filesystem * filesystem, - char const * path, - char const * filename) -{ - wfp_impl_static_filesystem_add_file(filesystem, path, filename); -} - -void -wfp_static_filesystem_add_generic( - struct wfp_static_filesystem * filesystem, - char const * path, - wfp_static_filesystem_read_fn * read, - wfp_static_filesystem_get_info_fn * get_info, - void * user_data) -{ - wfp_impl_static_filesystem_add_generic(filesystem, path, read, get_info, user_data); -} diff --git a/lib/webfuse/provider/impl/static_filesystem.h b/lib/webfuse/provider/impl/static_filesystem.h deleted file mode 100644 index a18835d..0000000 --- a/lib/webfuse/provider/impl/static_filesystem.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef WFP_IMPL_STATIC_FILESYSTEM_H -#define WFP_IMPL_STATIC_FILESYSTEM_H - -#include "webfuse/provider/static_filesystem.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -extern struct wfp_static_filesystem * -wfp_impl_static_filesystem_create( - struct wfp_client_config * config); - -extern void -wfp_impl_static_filesystem_dispose( - struct wfp_static_filesystem * filesystem); - -extern void -wfp_impl_static_filesystem_add( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content, - size_t length); - -extern void -wfp_impl_static_filesystem_add_text( - struct wfp_static_filesystem * filesystem, - char const * path, - int mode, - char const * content); - -extern void -wfp_impl_static_filesystem_add_file( - struct wfp_static_filesystem * filesystem, - char const * path, - char const * filename); - -extern void -wfp_impl_static_filesystem_add_generic( - struct wfp_static_filesystem * filesystem, - char const * path, - wfp_static_filesystem_read_fn * read, - wfp_static_filesystem_get_info_fn * get_info, - void * user_data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/test/webfuse/tests/core/test_path.cc b/test/webfuse/tests/core/test_path.cc deleted file mode 100644 index 93783ec..0000000 --- a/test/webfuse/tests/core/test_path.cc +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include "webfuse/core/path.h" - -TEST(wf_path, empty) -{ - struct wf_path * path = wf_path_create(""); - ASSERT_EQ(0, wf_path_element_count(path)); - ASSERT_EQ(nullptr, wf_path_get_element(path, 0)); - - wf_path_dispose(path); -} - -TEST(wf_path, relative_file) -{ - struct wf_path * path = wf_path_create("some.file"); - ASSERT_EQ(1, wf_path_element_count(path)); - ASSERT_STREQ("some.file", wf_path_get_element(path, 0)); - - wf_path_dispose(path); -} - -TEST(wf_path, absolute_file) -{ - struct wf_path * path = wf_path_create("/absolute.file"); - ASSERT_EQ(1, wf_path_element_count(path)); - ASSERT_STREQ("absolute.file", wf_path_get_element(path, 0)); - - wf_path_dispose(path); -} - -TEST(wf_path, nested_path) -{ - struct wf_path * path = wf_path_create("/a/nested/path"); - ASSERT_EQ(3, wf_path_element_count(path)); - ASSERT_STREQ("a", wf_path_get_element(path, 0)); - ASSERT_STREQ("nested", wf_path_get_element(path, 1)); - ASSERT_STREQ("path", wf_path_get_element(path, 2)); - - wf_path_dispose(path); -} - -TEST(wf_path, deep_nested_path) -{ - struct wf_path * path = wf_path_create("/this/is/a/very/deep/nested/path/to/some/file"); - ASSERT_EQ(10, wf_path_element_count(path)); - ASSERT_STREQ("this", wf_path_get_element(path, 0)); - ASSERT_STREQ("is", wf_path_get_element(path, 1)); - ASSERT_STREQ("a", wf_path_get_element(path, 2)); - ASSERT_STREQ("very", wf_path_get_element(path, 3)); - ASSERT_STREQ("deep", wf_path_get_element(path, 4)); - ASSERT_STREQ("nested", wf_path_get_element(path, 5)); - ASSERT_STREQ("path", wf_path_get_element(path, 6)); - ASSERT_STREQ("to", wf_path_get_element(path, 7)); - ASSERT_STREQ("some", wf_path_get_element(path, 8)); - ASSERT_STREQ("file", wf_path_get_element(path, 9)); - - wf_path_dispose(path); -} \ No newline at end of file diff --git a/test/webfuse/tests/integration/provider.cc b/test/webfuse/tests/integration/provider.cc index 49c334a..5142ca8 100644 --- a/test/webfuse/tests/integration/provider.cc +++ b/test/webfuse/tests/integration/provider.cc @@ -5,6 +5,7 @@ #include #include #include "webfuse/utils/msleep.hpp" +#include "webfuse/utils/static_filesystem.h" namespace webfuse_test { diff --git a/test/webfuse/tests/provider/test_static_filesystem.cc b/test/webfuse/tests/provider/test_static_filesystem.cc deleted file mode 100644 index 64a2736..0000000 --- a/test/webfuse/tests/provider/test_static_filesystem.cc +++ /dev/null @@ -1,61 +0,0 @@ -#include - -#include "webfuse/provider/impl/static_filesystem.h" -#include "webfuse/provider/client_config.h" -#include "webfuse/provider/impl/client_config.h" - -#include "webfuse/mocks/mock_request.hpp" - -using webfuse_test::request_create; -using webfuse_test::MockRequest; -using webfuse_test::GetAttrMatcher; -using webfuse_test::ReaddirMatcher; -using testing::_; - -TEST(wfp_static_filesystem, has_root_dir) -{ - struct wfp_client_config * config = wfp_client_config_create(); - struct wfp_static_filesystem * filesystem = wfp_impl_static_filesystem_create(config); - - MockRequest mock; - struct wfp_request * request = request_create(&mock, 42); - EXPECT_CALL(mock, respond(GetAttrMatcher(1, 0555, "dir"), 42)).Times(1); - - config->provider.getattr(request, 1, config->user_data); - - wfp_impl_static_filesystem_dispose(filesystem); - wfp_client_config_dispose(config); -} - -TEST(wfp_static_filesystem, contains_default_dirs) -{ - struct wfp_client_config * config = wfp_client_config_create(); - struct wfp_static_filesystem * filesystem = wfp_impl_static_filesystem_create(config); - - MockRequest mock; - struct wfp_request * request = request_create(&mock, 23); - char const * default_dirs[] = {".", "..", nullptr}; - EXPECT_CALL(mock, respond(ReaddirMatcher(default_dirs), 23)).Times(1); - - config->provider.readdir(request, 1, config->user_data); - - wfp_impl_static_filesystem_dispose(filesystem); - wfp_client_config_dispose(config); -} - -TEST(wfp_static_filesystem, add_text) -{ - struct wfp_client_config * config = wfp_client_config_create(); - struct wfp_static_filesystem * filesystem = wfp_impl_static_filesystem_create(config); - wfp_impl_static_filesystem_add_text(filesystem, "text.file", 666, "some text"); - - MockRequest mock; - struct wfp_request * request = request_create(&mock, 23); - char const * contained_elements[] = {"text.file", nullptr}; - EXPECT_CALL(mock, respond(ReaddirMatcher(contained_elements), 23)).Times(1); - - config->provider.readdir(request, 1, config->user_data); - - wfp_impl_static_filesystem_dispose(filesystem); - wfp_client_config_dispose(config); -} diff --git a/lib/webfuse/core/path.c b/test/webfuse/utils/path.c similarity index 98% rename from lib/webfuse/core/path.c rename to test/webfuse/utils/path.c index 36689f0..3cb222e 100644 --- a/lib/webfuse/core/path.c +++ b/test/webfuse/utils/path.c @@ -1,4 +1,4 @@ -#include "webfuse/core/path.h" +#include "webfuse/utils/path.h" #include #include diff --git a/lib/webfuse/core/path.h b/test/webfuse/utils/path.h similarity index 100% rename from lib/webfuse/core/path.h rename to test/webfuse/utils/path.h diff --git a/lib/webfuse/provider/impl/static_filesystem.c b/test/webfuse/utils/static_filesystem.c similarity index 75% rename from lib/webfuse/provider/impl/static_filesystem.c rename to test/webfuse/utils/static_filesystem.c index 83c3b92..7212e7a 100644 --- a/lib/webfuse/provider/impl/static_filesystem.c +++ b/test/webfuse/utils/static_filesystem.c @@ -1,9 +1,9 @@ -#include "webfuse/provider/impl/static_filesystem.h" +#include "webfuse/utils/static_filesystem.h" #include "webfuse/provider/client_config.h" #include "webfuse/provider/dirbuffer.h" #include "webfuse/provider/operation/error.h" -#include "webfuse/core/path.h" +#include "webfuse/utils/path.h" #include "webfuse/core/util.h" #include @@ -41,7 +41,7 @@ struct wfp_static_filesystem }; static struct wfp_static_filesystem_entry * -wfp_impl_static_filesystem_get_entry( +wfp_static_filesystem_get_entry( struct wfp_static_filesystem * filesystem, size_t inode) { @@ -56,7 +56,7 @@ wfp_impl_static_filesystem_get_entry( } static struct wfp_static_filesystem_entry * -wfp_impl_static_filesystem_get_entry_by_name( +wfp_static_filesystem_get_entry_by_name( struct wfp_static_filesystem * filesystem, size_t parent, char const * name) @@ -76,7 +76,7 @@ wfp_impl_static_filesystem_get_entry_by_name( } static struct wfp_static_filesystem_entry * -wfp_impl_static_filesystem_add_entry( +wfp_static_filesystem_add_entry( struct wfp_static_filesystem * filesystem) { struct wfp_static_filesystem_entry * entry = NULL; @@ -107,7 +107,7 @@ wfp_impl_static_filesystem_add_entry( } static size_t -wfp_impl_static_filesystem_entry_read( +wfp_static_filesystem_entry_read( size_t offset, char * buffer, size_t buffer_size, @@ -126,7 +126,7 @@ wfp_impl_static_filesystem_entry_read( } static void -wfp_impl_static_filesystem_entry_get_info( +wfp_static_filesystem_entry_get_info( void * user_data, int * result_mode, size_t * result_size) @@ -137,7 +137,7 @@ wfp_impl_static_filesystem_entry_get_info( } static size_t -wfp_impl_static_filesystem_file_read( +wfp_static_filesystem_file_read( size_t offset, char * buffer, size_t buffer_size, @@ -159,7 +159,7 @@ wfp_impl_static_filesystem_file_read( } static void -wfp_impl_static_filesystem_file_get_info( +wfp_static_filesystem_file_get_info( void * user_data, int * result_mode, size_t * result_size) @@ -176,23 +176,23 @@ wfp_impl_static_filesystem_file_get_info( static size_t -wfp_impl_static_filesystem_add_dir( +wfp_static_filesystem_add_dir( struct wfp_static_filesystem * filesystem, size_t parent, char const * name ) { - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_get_entry_by_name(filesystem, parent, name); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_get_entry_by_name(filesystem, parent, name); if (NULL == entry) { - entry = wfp_impl_static_filesystem_add_entry(filesystem); + entry = wfp_static_filesystem_add_entry(filesystem); entry->parent = parent; entry->is_file = false; entry->mode = 0555; entry->name = strdup(name); entry->user_data = entry; - entry->read = &wfp_impl_static_filesystem_entry_read; - entry->get_info = &wfp_impl_static_filesystem_entry_get_info; + entry->read = &wfp_static_filesystem_entry_read; + entry->get_info = &wfp_static_filesystem_entry_get_info; entry->size = 0; entry->content = NULL; } @@ -201,7 +201,7 @@ wfp_impl_static_filesystem_add_dir( } static size_t -wfp_impl_static_filesystem_make_parent( +wfp_static_filesystem_make_parent( struct wfp_static_filesystem * filesystem, struct wf_path * path) { @@ -213,7 +213,7 @@ wfp_impl_static_filesystem_make_parent( for(size_t i = 0; i < (count - 1); i++) { char const * name = wf_path_get_element(path, i); - result = wfp_impl_static_filesystem_add_dir(filesystem, result, name); + result = wfp_static_filesystem_add_dir(filesystem, result, name); } } @@ -221,7 +221,7 @@ wfp_impl_static_filesystem_make_parent( } static void -wfp_impl_static_filesystem_stat( +wfp_static_filesystem_stat( struct wfp_static_filesystem_entry * entry, struct stat * stat ) @@ -238,19 +238,19 @@ wfp_impl_static_filesystem_stat( stat->st_mode |= (entry->is_file) ? S_IFREG: S_IFDIR; } -static void wfp_impl_static_filesystem_lookup( +static void wfp_static_filesystem_lookup( struct wfp_request * request, ino_t parent, char const * name, void * user_data) { struct wfp_static_filesystem * filesystem = user_data; - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_get_entry_by_name(filesystem, parent, name); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_get_entry_by_name(filesystem, parent, name); if (NULL != entry) { struct stat stat; - wfp_impl_static_filesystem_stat(entry, &stat); + wfp_static_filesystem_stat(entry, &stat); wfp_respond_lookup(request, &stat); } else @@ -260,18 +260,18 @@ static void wfp_impl_static_filesystem_lookup( } -static void wfp_impl_static_filesystem_getattr( +static void wfp_static_filesystem_getattr( struct wfp_request * request, ino_t inode, void * user_data) { struct wfp_static_filesystem * filesystem = user_data; - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_get_entry(filesystem, inode); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_get_entry(filesystem, inode); if (NULL != entry) { struct stat stat; - wfp_impl_static_filesystem_stat(entry, &stat); + wfp_static_filesystem_stat(entry, &stat); wfp_respond_getattr(request, &stat); } else @@ -280,13 +280,13 @@ static void wfp_impl_static_filesystem_getattr( } } -static void wfp_impl_static_filesystem_readdir( +static void wfp_static_filesystem_readdir( struct wfp_request * request, ino_t directory, void * user_data) { struct wfp_static_filesystem * filesystem = user_data; - struct wfp_static_filesystem_entry * dir = wfp_impl_static_filesystem_get_entry(filesystem, directory); + struct wfp_static_filesystem_entry * dir = wfp_static_filesystem_get_entry(filesystem, directory); if ((NULL != dir) && (!dir->is_file)) { @@ -312,14 +312,14 @@ static void wfp_impl_static_filesystem_readdir( } } -static void wfp_impl_static_filesystem_open( +static void wfp_static_filesystem_open( struct wfp_request * request, ino_t inode, int flags, void * user_data) { struct wfp_static_filesystem * filesystem = user_data; - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_get_entry(filesystem, inode); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_get_entry(filesystem, inode); if ((NULL != entry) && (entry->is_file)) { @@ -338,7 +338,7 @@ static void wfp_impl_static_filesystem_open( } } -static void wfp_impl_static_filesystem_read( +static void wfp_static_filesystem_read( struct wfp_request * request, ino_t inode, uint32_t WF_UNUSED_PARAM(handle), @@ -347,7 +347,7 @@ static void wfp_impl_static_filesystem_read( void * user_data) { struct wfp_static_filesystem * filesystem = user_data; - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_get_entry(filesystem, inode); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_get_entry(filesystem, inode); if ((NULL != entry) && (entry->is_file)) { @@ -365,7 +365,7 @@ static void wfp_impl_static_filesystem_read( struct wfp_static_filesystem * -wfp_impl_static_filesystem_create( +wfp_static_filesystem_create( struct wfp_client_config * config) { (void) config; @@ -377,21 +377,21 @@ wfp_impl_static_filesystem_create( filesystem->size = 0; filesystem->capacity = WFP_STATIC_FILESYSTEM_DEFAULT_CAPACITY; - wfp_impl_static_filesystem_add_dir(filesystem, 0, ""); + wfp_static_filesystem_add_dir(filesystem, 0, ""); wfp_client_config_set_userdata(config, filesystem); - wfp_client_config_set_onlookup(config, &wfp_impl_static_filesystem_lookup); - wfp_client_config_set_ongetattr(config, &wfp_impl_static_filesystem_getattr); - wfp_client_config_set_onreaddir(config, &wfp_impl_static_filesystem_readdir); - wfp_client_config_set_onopen(config, &wfp_impl_static_filesystem_open); - wfp_client_config_set_onread(config, &wfp_impl_static_filesystem_read); + wfp_client_config_set_onlookup(config, &wfp_static_filesystem_lookup); + wfp_client_config_set_ongetattr(config, &wfp_static_filesystem_getattr); + wfp_client_config_set_onreaddir(config, &wfp_static_filesystem_readdir); + wfp_client_config_set_onopen(config, &wfp_static_filesystem_open); + wfp_client_config_set_onread(config, &wfp_static_filesystem_read); } return filesystem; } void -wfp_impl_static_filesystem_dispose( +wfp_static_filesystem_dispose( struct wfp_static_filesystem * filesystem) { for(size_t i = 0; i < filesystem->size; i++) @@ -406,7 +406,7 @@ wfp_impl_static_filesystem_dispose( } void -wfp_impl_static_filesystem_add( +wfp_static_filesystem_add( struct wfp_static_filesystem * filesystem, char const * path, int mode, @@ -416,15 +416,15 @@ wfp_impl_static_filesystem_add( struct wf_path * path_ = wf_path_create(path); if (NULL != path_) { - size_t parent = wfp_impl_static_filesystem_make_parent(filesystem, path_); - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_add_entry(filesystem); + size_t parent = wfp_static_filesystem_make_parent(filesystem, path_); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_add_entry(filesystem); entry->parent = parent; entry->is_file = true; entry->name = strdup(wf_path_get_filename(path_)); entry->mode = mode; entry->size = length; - entry->get_info = &wfp_impl_static_filesystem_entry_get_info; - entry->read = &wfp_impl_static_filesystem_entry_read; + entry->get_info = &wfp_static_filesystem_entry_get_info; + entry->read = &wfp_static_filesystem_entry_read; entry->user_data = entry; entry->content = malloc(length); @@ -435,18 +435,18 @@ wfp_impl_static_filesystem_add( } void -wfp_impl_static_filesystem_add_text( +wfp_static_filesystem_add_text( struct wfp_static_filesystem * filesystem, char const * path, int mode, char const * content) { size_t length = strlen(content); - wfp_impl_static_filesystem_add(filesystem, path, mode, content, length); + wfp_static_filesystem_add(filesystem, path, mode, content, length); } void -wfp_impl_static_filesystem_add_file( +wfp_static_filesystem_add_file( struct wfp_static_filesystem * filesystem, char const * path, char const * filename) @@ -454,16 +454,16 @@ wfp_impl_static_filesystem_add_file( struct wf_path * path_ = wf_path_create(path); if (NULL != path_) { - size_t parent = wfp_impl_static_filesystem_make_parent(filesystem, path_); - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_add_entry(filesystem); + size_t parent = wfp_static_filesystem_make_parent(filesystem, path_); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_add_entry(filesystem); entry->parent = parent; entry->is_file = true; entry->mode = 0; entry->content = strdup(filename); entry->size = 0; entry->name = strdup(wf_path_get_filename(path_)); - entry->get_info = &wfp_impl_static_filesystem_file_get_info; - entry->read = &wfp_impl_static_filesystem_file_read; + entry->get_info = &wfp_static_filesystem_file_get_info; + entry->read = &wfp_static_filesystem_file_read; entry->user_data = entry; wf_path_dispose(path_); @@ -471,7 +471,7 @@ wfp_impl_static_filesystem_add_file( } void -wfp_impl_static_filesystem_add_generic( +wfp_static_filesystem_add_generic( struct wfp_static_filesystem * filesystem, char const * path, wfp_static_filesystem_read_fn * read, @@ -481,8 +481,8 @@ wfp_impl_static_filesystem_add_generic( struct wf_path * path_ = wf_path_create(path); if (NULL != path_) { - size_t parent = wfp_impl_static_filesystem_make_parent(filesystem, path_); - struct wfp_static_filesystem_entry * entry = wfp_impl_static_filesystem_add_entry(filesystem); + size_t parent = wfp_static_filesystem_make_parent(filesystem, path_); + struct wfp_static_filesystem_entry * entry = wfp_static_filesystem_add_entry(filesystem); entry->parent = parent; entry->is_file = true; entry->mode = 0; diff --git a/test/webfuse/utils/static_filesystem.h b/test/webfuse/utils/static_filesystem.h new file mode 100644 index 0000000..4f72b1b --- /dev/null +++ b/test/webfuse/utils/static_filesystem.h @@ -0,0 +1,77 @@ +#ifndef WFP_STATIC_FILESYSTEM_H +#define WFP_STATIC_FILESYSTEM_H + +#ifndef __cplusplus +#include +#else +#include +using ::std::size_t; +#endif + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct wfp_client_config; + +struct wfp_static_filesystem; + +typedef size_t +wfp_static_filesystem_read_fn( + size_t offset, + char * buffer, + size_t buffer_size, + void * user_data); + +typedef void +wfp_static_filesystem_get_info_fn( + void * user_data, + int * result_mode, + size_t * result_size); + + +extern WFP_API struct wfp_static_filesystem * +wfp_static_filesystem_create( + struct wfp_client_config * config); + +extern WFP_API void +wfp_static_filesystem_dispose( + struct wfp_static_filesystem * filesystem); + +extern WFP_API void +wfp_static_filesystem_add( + struct wfp_static_filesystem * filesystem, + char const * path, + int mode, + char const * content, + size_t length); + +extern WFP_API void +wfp_static_filesystem_add_text( + struct wfp_static_filesystem * filesystem, + char const * path, + int mode, + char const * content); + +extern WFP_API void +wfp_static_filesystem_add_file( + struct wfp_static_filesystem * filesystem, + char const * path, + char const * filename); + +extern WFP_API void +wfp_static_filesystem_add_generic( + struct wfp_static_filesystem * filesystem, + char const * path, + wfp_static_filesystem_read_fn * read, + wfp_static_filesystem_get_info_fn * get_info, + void * user_data); + +#ifdef __cplusplus +} +#endif + +#endif