removed uuid mountpoint and factory

pull/2/head
Falk Werner 4 years ago
parent 428c192910
commit 43c989e7af

@ -15,9 +15,9 @@ RUN set -x \
pkgconf \
rsync \
gdb \
valgrind \
util-linux \
util-linux-dev
valgrind
# util-linux \
# util-linux-dev
COPY src /usr/local/src

@ -15,8 +15,7 @@ RUN set -x \
gdb \
gdbserver \
valgrind \
lcov \
uuid-dev
lcov
COPY src /usr/local/src

@ -19,9 +19,9 @@ RUN set -x \
pkgconf \
rsync \
gdb \
valgrind \
util-linux \
util-linux-dev
valgrind
# util-linux \
# util-linux-dev
COPY src /usr/local/src

@ -18,8 +18,7 @@ RUN set -x \
rsync \
gdb \
gdbserver \
lcov \
uuid-dev
lcov
COPY src /usr/local/src

@ -40,8 +40,6 @@ add_executable(alltests
test/webfuse/tests/adapter/test_authenticator.cc
test/webfuse/tests/adapter/test_authenticators.cc
test/webfuse/tests/adapter/test_mountpoint.cc
test/webfuse/tests/adapter/test_uuid_mountpoint.cc
test/webfuse/tests/adapter/test_uuid_mountpoint_factory.cc
test/webfuse/tests/adapter/test_fuse_req.cc
test/webfuse/tests/provider/test_url.cc
test/webfuse/tests/provider/test_client_protocol.cc
@ -56,12 +54,10 @@ target_include_directories(alltests PRIVATE
lib/wf/timer/include
lib/wf/timer/src
${FUSE3_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
)
target_compile_options(alltests PUBLIC
${FUSE3_CFLAGS_OTHER}
${UUID_CFLAGS_OTHER}
)
target_link_libraries(alltests PUBLIC
@ -73,7 +69,6 @@ target_link_libraries(alltests PUBLIC
${FUSE3_LIBRARIES}
${LWS_LIBRARIES}
${JANSSON_LIBRARIES}
${UUID_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${GMOCK_LIBRARIES}
${GTEST_LIBRARIES}

@ -1,7 +1,6 @@
if(NOT WITHOUT_ADAPTER)
pkg_check_modules(FUSE3 REQUIRED fuse3)
pkg_check_modules(UUID REQUIRED uuid)
add_library(webfuse-adapter-static STATIC
lib/webfuse/adapter/api.c
@ -17,8 +16,6 @@ add_library(webfuse-adapter-static STATIC
lib/webfuse/adapter/impl/operations.c
lib/webfuse/adapter/impl/mountpoint.c
lib/webfuse/adapter/impl/mountpoint_factory.c
lib/webfuse/adapter/impl/uuid_mountpoint_factory.c
lib/webfuse/adapter/impl/uuid_mountpoint.c
lib/webfuse/adapter/impl/operation/lookup.c
lib/webfuse/adapter/impl/operation/getattr.c
lib/webfuse/adapter/impl/operation/readdir.c
@ -32,12 +29,10 @@ target_include_directories(webfuse-adapter-static PRIVATE
lib/wf/timer/include
lib/wf/jsonrpc/include
${FUSE3_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
)
target_compile_options(webfuse-adapter-static PUBLIC
${FUSE3_CFLAGS_OTHER}
${UUID_CFLAGS_OTHER}
)
set_target_properties(webfuse-adapter-static PROPERTIES OUTPUT_NAME webfuse-adapter)
@ -49,12 +44,10 @@ add_library(webfuse-adapter SHARED
target_include_directories(webfuse-adapter PRIVATE
${FUSE3_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
)
target_compile_options(webfuse-adapter PUBLIC
${FUSE3_CFLAGS_OTHER}
${UUID_CFLAGS_OTHER}
)

@ -42,23 +42,6 @@ extern WF_API struct wf_server_config * wf_server_config_create(void);
extern WF_API void wf_server_config_dispose(
struct wf_server_config * config);
//------------------------------------------------------------------------------
/// \brief Sets a mountpoint path.
/// \deprecated This function will be removed soon. Use \ref
/// wf_server_config_set_mountpoint_factory instead.
///
/// Sets the root path of UUID-based file system.
///
/// \note A valid configuration needs either a mountpoint or a mounpoint
/// factory.
///
/// \param config pointer of configuration object
/// \param mount_point root path of UUID-based file system.
//------------------------------------------------------------------------------
extern WF_API void wf_server_config_set_mountpoint(
struct wf_server_config * config,
char const * mount_point);
//------------------------------------------------------------------------------
/// \brief Sets the mountpoint factory of the configuration.
///

@ -38,12 +38,6 @@ void wf_server_interrupt(
// server protocol
struct wf_server_protocol * wf_server_protocol_create(
char * mount_point)
{
return wf_impl_server_protocol_create(mount_point);
}
struct wf_server_protocol * wf_server_protocol_create2(
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context)
@ -86,13 +80,6 @@ void wf_server_config_dispose(
wf_impl_server_config_dispose(config);
}
void wf_server_config_set_mountpoint(
struct wf_server_config * config,
char const * mount_point)
{
wf_impl_server_config_set_mountpoint(config, mount_point);
}
void wf_server_config_set_mountpoint_factory(
struct wf_server_config * config,
wf_create_mountpoint_fn * create_mountpoint,

@ -6,7 +6,6 @@
#include "webfuse/core/string.h"
#include <libwebsockets.h>
#include <uuid/uuid.h>
#include <sys/stat.h>
#include <sys/types.h>

@ -7,19 +7,16 @@ wf_impl_mountpoint_factory_init_default(
{
factory->create_mountpoint = NULL;
factory->user_data = NULL;
factory->dispose = NULL;
}
void
wf_impl_mountpoint_factory_init(
struct wf_impl_mountpoint_factory * factory,
wf_create_mountpoint_fn * create_mountpoint,
void * user_data,
wf_impl_mountpoint_factory_dispose_fn * dispose)
void * user_data)
{
factory->create_mountpoint = create_mountpoint;
factory->user_data = user_data;
factory->dispose = dispose;
}
void
@ -29,10 +26,8 @@ wf_impl_mountpoint_factory_move(
{
other->create_mountpoint = factory->create_mountpoint;
other->user_data = factory->user_data;
other->dispose = factory->dispose;
factory->create_mountpoint = NULL;
factory->dispose = NULL;
factory->user_data = NULL;
}
@ -47,13 +42,8 @@ void
wf_impl_mountpoint_factory_cleanup(
struct wf_impl_mountpoint_factory * factory)
{
if (NULL != factory->dispose)
{
factory->dispose(factory->user_data);
}
factory->create_mountpoint = NULL;
factory->dispose = NULL;
factory->user_data = NULL;
}

@ -9,14 +9,9 @@ extern "C"
{
#endif
typedef void
wf_impl_mountpoint_factory_dispose_fn(
void * user_data);
struct wf_impl_mountpoint_factory
{
wf_create_mountpoint_fn * create_mountpoint;
wf_impl_mountpoint_factory_dispose_fn * dispose;
void * user_data;
};
@ -28,8 +23,7 @@ extern void
wf_impl_mountpoint_factory_init(
struct wf_impl_mountpoint_factory * factory,
wf_create_mountpoint_fn * create_mountpoint,
void * user_data,
wf_impl_mountpoint_factory_dispose_fn * dispose);
void * user_data);
extern void
wf_impl_mountpoint_factory_move(

@ -1,5 +1,4 @@
#include "webfuse/adapter/impl/server_config.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include <stdlib.h>
#include <string.h>
@ -72,21 +71,13 @@ void wf_impl_server_config_dispose(
free(config);
}
void wf_impl_server_config_set_mountpoint(
struct wf_server_config * config,
char const * mount_point)
{
wf_impl_uuid_mountpoint_factory_init(&config->mountpoint_factory,
mount_point);
}
void wf_impl_server_config_set_mountpoint_factory(
struct wf_server_config * config,
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context)
{
wf_impl_mountpoint_factory_init(&config->mountpoint_factory,
create_mountpoint, create_mountpoint_context, NULL);
create_mountpoint, create_mountpoint_context);
}

@ -34,10 +34,6 @@ extern void wf_impl_server_config_clone(
struct wf_server_config * config,
struct wf_server_config * clone);
extern void wf_impl_server_config_set_mountpoint(
struct wf_server_config * config,
char const * mount_point);
extern void wf_impl_server_config_set_mountpoint_factory(
struct wf_server_config * config,
wf_create_mountpoint_fn * create_mountpoint,

@ -9,7 +9,6 @@
#include "webfuse/core/protocol_names.h"
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "webfuse/core/status_intern.h"
#include "wf/jsonrpc/request.h"
@ -81,21 +80,6 @@ static int wf_impl_server_protocol_callback(
return 0;
}
struct wf_server_protocol * wf_impl_server_protocol_create(
char * mount_point)
{
struct wf_server_protocol * protocol = malloc(sizeof(struct wf_server_protocol));
if (NULL != protocol)
{
struct wf_impl_mountpoint_factory mountpoint_factory;
wf_impl_uuid_mountpoint_factory_init(&mountpoint_factory, mount_point);
wf_impl_server_protocol_init(protocol, &mountpoint_factory);
}
return protocol;
}
struct wf_server_protocol * wf_impl_server_protocol_create2(
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context)
@ -105,7 +89,7 @@ struct wf_server_protocol * wf_impl_server_protocol_create2(
{
struct wf_impl_mountpoint_factory mountpoint_factory;
wf_impl_mountpoint_factory_init(&mountpoint_factory,
create_mountpoint, create_mountpoint_context, NULL);
create_mountpoint, create_mountpoint_context);
wf_impl_server_protocol_init(protocol, &mountpoint_factory);
}

@ -36,9 +36,6 @@ extern void wf_impl_server_protocol_init(
extern void wf_impl_server_protocol_cleanup(
struct wf_server_protocol * protocol);
extern struct wf_server_protocol * wf_impl_server_protocol_create(
char * mount_point);
extern WF_API struct wf_server_protocol * wf_impl_server_protocol_create2(
wf_create_mountpoint_fn * create_mountpoint,
void * create_mountpoint_context);

@ -1,124 +0,0 @@
#include "webfuse/adapter/impl/uuid_mountpoint.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/core/string.h"
#include <uuid/uuid.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
struct wf_impl_uuid_mountpoint_data
{
char * id;
char * filesystem_path;
char * default_path;
char * full_path;
};
static char * wf_impl_uuid_mountpoint_create_id(void)
{
uuid_t uuid;
uuid_generate(uuid);
char id[UUID_STR_LEN];
uuid_unparse(uuid, id);
return strdup(id);
}
static bool wf_impl_uuid_mountpoint_is_link_broken(char const * path, char const * id)
{
bool result = false;
char buffer[UUID_STR_LEN];
ssize_t count = readlink(path, buffer, UUID_STR_LEN);
if ((0 < count) && (count < UUID_STR_LEN))
{
buffer[count] = '\0';
result = (0 == strcmp(buffer, id));
}
return result;
}
static bool wf_impl_uuid_mountpoint_link_first_subdir(
char const * link_path,
char const * path)
{
bool result = false;
DIR * dir = opendir(path);
if (NULL != dir)
{
struct dirent * entry = readdir(dir);
while (NULL != entry)
{
if ((DT_DIR == entry->d_type) && ('.' != entry->d_name[0]))
{
int rc = symlink(entry->d_name, link_path);
result = (0 == rc);
break;
}
entry = readdir(dir);
}
closedir(dir);
}
return result;
}
static void
wf_impl_uuid_mountpoint_data_dispose(
void * user_data)
{
struct wf_impl_uuid_mountpoint_data * data = user_data;
rmdir(data->full_path);
if (wf_impl_uuid_mountpoint_is_link_broken(data->default_path, data->id))
{
unlink(data->default_path);
bool const success = wf_impl_uuid_mountpoint_link_first_subdir(data->default_path, data->filesystem_path);
if (!success)
{
rmdir(data->filesystem_path);
}
}
free(data->id);
free(data->filesystem_path);
free(data->default_path);
free(data->full_path);
free(data);
}
struct wf_mountpoint *
wf_impl_uuid_mountpoint_create(
char const * root_path,
char const * filesystem)
{
struct wf_impl_uuid_mountpoint_data * data = malloc(sizeof(struct wf_impl_uuid_mountpoint_data));
data->filesystem_path = wf_create_string("%s/%s", root_path, filesystem);
mkdir(data->filesystem_path, 0755);
data->id = wf_impl_uuid_mountpoint_create_id();
data->full_path = wf_create_string("%s/%s/%s", root_path, filesystem, data->id);
mkdir(data->full_path, 0755);
data->default_path = wf_create_string("%s/%s/default", root_path, filesystem);
int rc = symlink(data->id, data->default_path);
(void) rc; // ignore missing symlink
struct wf_mountpoint * mountpoint = wf_impl_mountpoint_create(data->full_path);
wf_impl_mountpoint_set_userdata(mountpoint, data, &wf_impl_uuid_mountpoint_data_dispose);
return mountpoint;
}

@ -1,20 +0,0 @@
#ifndef WF_IMPL_UUID_MOUNTPOINT_H
#define WF_IMPL_UUID_MOUNTPOINT_H
#ifdef __cplusplus
extern "C"
{
#endif
struct wf_mountpoint;
extern struct wf_mountpoint *
wf_impl_uuid_mountpoint_create(
char const * root_path,
char const * filesystem);
#ifdef __cplusplus
}
#endif
#endif

@ -1,84 +0,0 @@
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "webfuse/adapter/impl/uuid_mountpoint.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
struct wf_impl_uuid_mountpoint_factory
{
char * root_path;
bool root_created;
};
static void *
wf_impl_uuid_mountpoint_factory_create_context(
char const * root_path)
{
struct wf_impl_uuid_mountpoint_factory * factory = NULL;
bool root_created = false;
struct stat info;
int rc = stat(root_path, &info);
if ((0 != rc) || (!S_ISDIR(info.st_mode)))
{
rc = mkdir(root_path, 0755);
root_created = true;
}
if (0 == rc)
{
factory = malloc(sizeof(struct wf_impl_uuid_mountpoint_factory));
factory->root_path = strdup(root_path);
factory->root_created = root_created;
}
return factory;
}
static void
wf_impl_uuid_mountpoint_factory_dispose(
void * user_data)
{
struct wf_impl_uuid_mountpoint_factory * factory = user_data;
if (factory->root_created)
{
rmdir(factory->root_path);
}
free(factory->root_path);
free(factory);
}
static struct wf_mountpoint *
wf_impl_uuid_mountpoint_factory_create_mountpoint(
char const * filesystem,
void * user_data)
{
struct wf_impl_uuid_mountpoint_factory * factory = user_data;
return wf_impl_uuid_mountpoint_create(factory->root_path, filesystem);
}
bool
wf_impl_uuid_mountpoint_factory_init(
struct wf_impl_mountpoint_factory * factory,
char const * root_path)
{
void * context = wf_impl_uuid_mountpoint_factory_create_context(root_path);
bool const result = (NULL != context);
if (result)
{
factory->create_mountpoint = &wf_impl_uuid_mountpoint_factory_create_mountpoint;
factory->user_data = context;
factory->dispose = &wf_impl_uuid_mountpoint_factory_dispose;
}
return result;
}

@ -1,21 +0,0 @@
#ifndef WF_IMPL_UUID_MOUNTPOINT_FACTORY_H
#define WF_IMPL_UUID_MOUNTPOINT_FACTORY_H
#include "webfuse/adapter/impl/mountpoint_factory.h"
#include <stdbool.h>
#ifdef __cplusplus
extern "C"
{
#endif
extern bool
wf_impl_uuid_mountpoint_factory_init(
struct wf_impl_mountpoint_factory * factory,
char const * root_path);
#ifdef __cplusplus
}
#endif
#endif

@ -8,13 +8,27 @@
#include "webfuse/adapter/server.h"
#include "webfuse/adapter/server_config.h"
namespace
{
struct wf_mountpoint *
create_mountpoint(
char const * filesystem,
void * user_data)
{
(void) filesystem;
(void) user_data;
return nullptr;
}
}
TEST(server, create_dispose)
{
mkdir("test", 0700);
struct wf_server_config * config = wf_server_config_create();
wf_server_config_set_mountpoint(config, "test");
wf_server_config_set_mountpoint_factory(config, &create_mountpoint, nullptr);
struct wf_server * server = wf_server_create(config);
ASSERT_NE(nullptr, server);

@ -120,38 +120,18 @@ TEST(server_config, set_port)
wf_server_config_dispose(config);
}
TEST(server_config, set_mountpoint)
{
TempDir temp("server_config");
wf_server_config * config = wf_server_config_create();
ASSERT_NE(nullptr, config);
ASSERT_EQ(nullptr, config->mountpoint_factory.create_mountpoint);
ASSERT_EQ(nullptr, config->mountpoint_factory.user_data);
ASSERT_EQ(nullptr, config->mountpoint_factory.dispose);
wf_server_config_set_mountpoint(config, temp.path());
ASSERT_NE(nullptr, config->mountpoint_factory.create_mountpoint);
ASSERT_NE(nullptr, config->mountpoint_factory.user_data);
ASSERT_NE(nullptr, config->mountpoint_factory.dispose);
wf_server_config_dispose(config);
}
TEST(server_config, set_mounpoint_factory)
{
wf_server_config * config = wf_server_config_create();
ASSERT_NE(nullptr, config);
ASSERT_EQ(nullptr, config->mountpoint_factory.create_mountpoint);
ASSERT_EQ(nullptr, config->mountpoint_factory.user_data);
ASSERT_EQ(nullptr, config->mountpoint_factory.dispose);
int value = 42;
void * user_data = reinterpret_cast<void*>(&value);
wf_server_config_set_mountpoint_factory(config, &create_mountpoint, user_data);
ASSERT_EQ(&create_mountpoint, config->mountpoint_factory.create_mountpoint);
ASSERT_EQ(user_data, config->mountpoint_factory.user_data);
ASSERT_EQ(nullptr, config->mountpoint_factory.dispose);
wf_server_config_dispose(config);
}

@ -1,72 +0,0 @@
#include <gtest/gtest.h>
#include "webfuse/utils/tempdir.hpp"
#include "webfuse/utils/file_utils.hpp"
#include "webfuse_adapter.h"
#include "webfuse/adapter/impl/uuid_mountpoint.h"
#include <string>
using webfuse_test::TempDir;
using webfuse_test::is_dir;
using webfuse_test::is_symlink;
using webfuse_test::is_same_path;
TEST(uuid_mountpoint, create)
{
TempDir temp("uuid_mountpoint");
std::string filesystem_path = std::string(temp.path()) + "/dummy";
std::string default_path = std::string(temp.path()) + "/dummy/default";
wf_mountpoint * mountpoint = wf_impl_uuid_mountpoint_create(temp.path(), "dummy");
std::string path = wf_mountpoint_get_path(mountpoint);
ASSERT_NE(nullptr, mountpoint);
ASSERT_TRUE(is_dir(filesystem_path));
ASSERT_TRUE(is_symlink(default_path));
ASSERT_TRUE(is_dir(default_path));
ASSERT_TRUE(is_dir(path));
ASSERT_TRUE(is_same_path(default_path, path));
wf_mountpoint_dispose(mountpoint);
ASSERT_FALSE(is_dir(filesystem_path));
ASSERT_FALSE(is_symlink(default_path));
ASSERT_FALSE(is_dir(default_path));
ASSERT_FALSE(is_dir(path));
}
TEST(uuid_mountpoint, relink_default)
{
TempDir temp("uuid_mountpoint");
std::string filesystem_path = std::string(temp.path()) + "/dummy";
std::string default_path = std::string(temp.path()) + "/dummy/default";
wf_mountpoint * mountpoint_a = wf_impl_uuid_mountpoint_create(temp.path(), "dummy");
std::string path_a = wf_mountpoint_get_path(mountpoint_a);
wf_mountpoint * mountpoint_b = wf_impl_uuid_mountpoint_create(temp.path(), "dummy");
std::string path_b = wf_mountpoint_get_path(mountpoint_b);
ASSERT_TRUE(is_dir(filesystem_path));
ASSERT_TRUE(is_symlink(default_path));
ASSERT_TRUE(is_dir(default_path));
ASSERT_TRUE(is_dir(path_a));
ASSERT_TRUE(is_dir(path_b));
ASSERT_TRUE(is_same_path(default_path, path_a));
wf_mountpoint_dispose(mountpoint_a);
ASSERT_TRUE(is_dir(filesystem_path));
ASSERT_TRUE(is_symlink(default_path));
ASSERT_TRUE(is_dir(default_path));
ASSERT_FALSE(is_dir(path_a));
ASSERT_TRUE(is_dir(path_b));
ASSERT_TRUE(is_same_path(default_path, path_b));
wf_mountpoint_dispose(mountpoint_b);
ASSERT_FALSE(is_dir(filesystem_path));
ASSERT_FALSE(is_symlink(default_path));
ASSERT_FALSE(is_dir(default_path));
ASSERT_FALSE(is_dir(path_a));
ASSERT_FALSE(is_dir(path_b));
}

@ -1,61 +0,0 @@
#include <gtest/gtest.h>
#include "webfuse_adapter.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "webfuse/utils/tempdir.hpp"
#include "webfuse/utils/file_utils.hpp"
using webfuse_test::TempDir;
using webfuse_test::is_dir;
TEST(uuid_mountpoint_factory, create_existing_dir)
{
TempDir temp("uuid_mountpoint_factory");
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, temp.path());
ASSERT_TRUE(factory_created);
ASSERT_TRUE(is_dir(temp.path()));
wf_mountpoint * mountpoint = wf_impl_mountpoint_factory_create_mountpoint(&factory, "dummy");
std::string path = wf_mountpoint_get_path(mountpoint);
ASSERT_TRUE(is_dir(path));
wf_mountpoint_dispose(mountpoint);
ASSERT_FALSE(is_dir(path));
wf_impl_mountpoint_factory_cleanup(&factory);
// keep dir not created by factory
ASSERT_TRUE(is_dir(temp.path()));
}
TEST(uuid_mountpoint_factory, create_nonexisting_dir)
{
TempDir temp("uuid_mountpoint_factory");
std::string root_path = std::string(temp.path()) + "/root";
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, root_path.c_str());
ASSERT_TRUE(factory_created);
ASSERT_TRUE(is_dir(root_path));
wf_mountpoint * mountpoint = wf_impl_mountpoint_factory_create_mountpoint(&factory, "dummy");
std::string path = wf_mountpoint_get_path(mountpoint);
ASSERT_TRUE(is_dir(path));
wf_mountpoint_dispose(mountpoint);
ASSERT_FALSE(is_dir(path));
wf_impl_mountpoint_factory_cleanup(&factory);
// remove dir, created by factory
ASSERT_FALSE(is_dir(root_path));
}
TEST(uuid_mountpoint_factory, fail_to_created_nested_dir)
{
TempDir temp("uuid_mountpoint_factory");
std::string root_path = std::string(temp.path()) + "/nested/root";
struct wf_impl_mountpoint_factory factory;
bool factory_created = wf_impl_uuid_mountpoint_factory_init(&factory, root_path.c_str());
ASSERT_FALSE(factory_created);
}

@ -4,11 +4,43 @@
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <sys/stat.h>
#include "webfuse_adapter.h"
#include "webfuse/adapter/impl/server.h"
#define WF_PATH_MAX (100)
extern "C"
{
static void webfuse_test_server_cleanup_mountpoint(
void * user_data)
{
char * path = reinterpret_cast<char*>(user_data);
rmdir(path);
free(path);
}
static struct wf_mountpoint *
webfuse_test_server_create_mountpoint(
char const * filesystem,
void * user_data)
{
char const * base_dir = reinterpret_cast<char const*>(user_data);
char path[WF_PATH_MAX];
snprintf(path, WF_PATH_MAX, "%s/%s", base_dir, filesystem);
mkdir(path, 0755);
struct wf_mountpoint * mountpoint = wf_mountpoint_create(path);
wf_mountpoint_set_userdata(
mountpoint,
reinterpret_cast<void*>(strdup(path)),
&webfuse_test_server_cleanup_mountpoint);
return mountpoint;
}
}
namespace webfuse_test
{
@ -28,7 +60,9 @@ public:
config = wf_server_config_create();
wf_server_config_set_port(config, 8080);
wf_server_config_set_mountpoint(config, base_dir);
wf_server_config_set_mountpoint_factory(config,
&webfuse_test_server_create_mountpoint,
reinterpret_cast<void*>(base_dir));
server = wf_server_create(config);

@ -68,7 +68,7 @@ TEST_F(IntegrationTest, HasMountpoint)
TEST_F(IntegrationTest, ProvidesTextFile)
{
std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt";
std::string file_name = std::string(GetBaseDir()) + "/cprovider/hello.txt";
ASSERT_EXIT({
struct stat buffer;
@ -85,7 +85,7 @@ TEST_F(IntegrationTest, ProvidesTextFile)
TEST_F(IntegrationTest, ReadTextFile)
{
std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt";
std::string file_name = std::string(GetBaseDir()) + "/cprovider/hello.txt";
ASSERT_EXIT({
FILE * file = fopen(file_name.c_str(), "rb");
@ -106,7 +106,7 @@ TEST_F(IntegrationTest, ReadTextFile)
TEST_F(IntegrationTest, ReadDir)
{
std::string dir_name = std::string(GetBaseDir()) + "/cprovider/default";
std::string dir_name = std::string(GetBaseDir()) + "/cprovider";
ASSERT_EXIT({

Loading…
Cancel
Save