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

added unit tests of uuid_mountpoint_factory

This commit is contained in:
Falk Werner
2020-02-16 17:33:11 +01:00
parent 096c244445
commit 2b91f159cf
7 changed files with 148 additions and 41 deletions

View File

@@ -7,20 +7,36 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
struct wf_impl_uuid_mountpoint_factory
{
char * root_path;
bool root_created;
};
void *
wf_impl_uuid_mountpoint_factory_create(
char * root_path)
char const * root_path)
{
mkdir(root_path, 0755);
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;
}
struct wf_impl_uuid_mountpoint_factory * factory = malloc(sizeof(struct wf_impl_uuid_mountpoint_factory));
factory->root_path = strdup(root_path);
return factory;
}
@@ -31,7 +47,11 @@ wf_impl_uuid_mountpoint_factory_dispose(
{
struct wf_impl_uuid_mountpoint_factory * factory = user_data;
rmdir(factory->root_path);
if (factory->root_created)
{
rmdir(factory->root_path);
}
free(factory->root_path);
free(factory);
}

View File

@@ -10,14 +10,14 @@ struct wf_mountpoint;
extern void *
wf_impl_uuid_mountpoint_factory_create(
char * root_path);
char const * root_path);
extern void
wf_impl_uuid_mountpoint_factory_dispose(
void * user_data);
extern struct wf_mountpoint *
wf_impl_uuid_mountpoint_factory_create_mountpiont(
wf_impl_uuid_mountpoint_factory_create_mountpoint(
char const * filesystem,
void * user_data);