mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
feature: allow to specify mount options
This commit is contained in:
parent
77ede52c92
commit
9f08154af9
@ -45,7 +45,7 @@ wf_mountpoint_create(
|
||||
///
|
||||
/// \param mountpoint pointer to the mountpoint
|
||||
//------------------------------------------------------------------------------
|
||||
extern WF_API void
|
||||
extern WF_API void
|
||||
wf_mountpoint_dispose(
|
||||
struct wf_mountpoint * mountpoint);
|
||||
|
||||
@ -55,7 +55,7 @@ wf_mountpoint_dispose(
|
||||
/// \param mountpoint pointer to the mountpoint
|
||||
/// \return local path of the mountpoint
|
||||
//------------------------------------------------------------------------------
|
||||
extern WF_API char const *
|
||||
extern WF_API char const *
|
||||
wf_mountpoint_get_path(
|
||||
struct wf_mountpoint const * mountpoint);
|
||||
|
||||
@ -76,6 +76,20 @@ wf_mountpoint_set_userdata(
|
||||
void * user_data,
|
||||
wf_mountpoint_userdata_dispose_fn * dispose);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// \brief Adds a mount option.
|
||||
///
|
||||
/// Mount options are passed to libfuse when a filesystem is mounted.
|
||||
/// See libfuse documenation for allowed values.
|
||||
///
|
||||
/// \param mountpoint pointer to the mountpooint
|
||||
/// \param option value of the mount option
|
||||
//------------------------------------------------------------------------------
|
||||
extern WF_API void
|
||||
wf_mountpoint_add_mountoption(
|
||||
struct wf_mountpoint * mountpoint,
|
||||
char const * option);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -140,7 +140,7 @@ void wf_server_config_add_authenticator(
|
||||
wf_impl_server_config_add_authenticator(config, type, authenticate, user_data);
|
||||
}
|
||||
|
||||
// credentials
|
||||
// credentials
|
||||
|
||||
char const * wf_credentials_type(
|
||||
struct wf_credentials const * credentials)
|
||||
@ -179,14 +179,14 @@ wf_mountpoint_create(
|
||||
return wf_impl_mountpoint_create(path);
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
wf_mountpoint_dispose(
|
||||
struct wf_mountpoint * mountpoint)
|
||||
{
|
||||
wf_impl_mountpoint_dispose(mountpoint);
|
||||
}
|
||||
|
||||
char const *
|
||||
char const *
|
||||
wf_mountpoint_get_path(
|
||||
struct wf_mountpoint const * mountpoint)
|
||||
{
|
||||
@ -202,6 +202,14 @@ wf_mountpoint_set_userdata(
|
||||
wf_impl_mountpoint_set_userdata(mountpoint, user_data, dispose);
|
||||
}
|
||||
|
||||
void
|
||||
wf_mountpoint_add_mountoption(
|
||||
struct wf_mountpoint * mountpoint,
|
||||
char const * option)
|
||||
{
|
||||
wf_impl_mountpoint_add_mountoption(mountpoint, option);
|
||||
}
|
||||
|
||||
// client
|
||||
|
||||
struct wf_client *
|
||||
|
@ -37,17 +37,16 @@ static void wf_impl_filesystem_cleanup(
|
||||
fuse_session_reset(filesystem->session);
|
||||
fuse_session_unmount(filesystem->session);
|
||||
fuse_session_destroy(filesystem->session);
|
||||
filesystem->session = NULL;
|
||||
filesystem->session = NULL;
|
||||
|
||||
free(filesystem->buffer.mem);
|
||||
fuse_opt_free_args(&filesystem->args);
|
||||
fuse_opt_free_args(&filesystem->args);
|
||||
|
||||
wf_mountpoint_dispose(filesystem->mountpoint);
|
||||
|
||||
free(filesystem->user_data.name);
|
||||
}
|
||||
|
||||
|
||||
static bool wf_impl_filesystem_init(
|
||||
struct wf_impl_filesystem * filesystem,
|
||||
struct lws * session_wsi,
|
||||
@ -56,10 +55,9 @@ static bool wf_impl_filesystem_init(
|
||||
struct wf_mountpoint * mountpoint)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
char * argv[] = {"", NULL};
|
||||
filesystem->args.argc = 1;
|
||||
filesystem->args.argv = argv;
|
||||
|
||||
filesystem->args.argc = mountpoint->options.size;
|
||||
filesystem->args.argv = mountpoint->options.items;
|
||||
filesystem->args.allocated = 0;
|
||||
|
||||
filesystem->user_data.proxy = proxy;
|
||||
@ -90,7 +88,7 @@ static bool wf_impl_filesystem_init(
|
||||
if (NULL == filesystem->wsi)
|
||||
{
|
||||
wf_impl_filesystem_cleanup(filesystem);
|
||||
result = false;
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct wf_mountpoint
|
||||
{
|
||||
char * path;
|
||||
void * user_data;
|
||||
wf_mountpoint_userdata_dispose_fn * dispose;
|
||||
};
|
||||
#define WF_MOUNTOPTIONS_INITIAL_CAPACITY 8
|
||||
|
||||
struct wf_mountpoint *
|
||||
wf_impl_mountpoint_create(
|
||||
@ -18,11 +13,16 @@ wf_impl_mountpoint_create(
|
||||
mountpoint->path = strdup(path);
|
||||
mountpoint->user_data = NULL;
|
||||
mountpoint->dispose = NULL;
|
||||
mountpoint->options.size = 1;
|
||||
mountpoint->options.capacity = WF_MOUNTOPTIONS_INITIAL_CAPACITY;
|
||||
mountpoint->options.items = malloc(sizeof(char*) * mountpoint->options.capacity);
|
||||
mountpoint->options.items[0] = strdup("");
|
||||
mountpoint->options.items[1] = NULL;
|
||||
|
||||
return mountpoint;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
wf_impl_mountpoint_dispose(
|
||||
struct wf_mountpoint * mountpoint)
|
||||
{
|
||||
@ -31,11 +31,17 @@ wf_impl_mountpoint_dispose(
|
||||
mountpoint->dispose(mountpoint->user_data);
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < mountpoint->options.size; i++)
|
||||
{
|
||||
free(mountpoint->options.items[i]);
|
||||
}
|
||||
free(mountpoint->options.items);
|
||||
|
||||
free(mountpoint->path);
|
||||
free(mountpoint);
|
||||
}
|
||||
|
||||
char const *
|
||||
char const *
|
||||
wf_impl_mountpoint_get_path(
|
||||
struct wf_mountpoint const * mountpoint)
|
||||
{
|
||||
@ -51,3 +57,20 @@ wf_impl_mountpoint_set_userdata(
|
||||
mountpoint->user_data = user_data;
|
||||
mountpoint->dispose = dispose;
|
||||
}
|
||||
|
||||
void
|
||||
wf_impl_mountpoint_add_mountoption(
|
||||
struct wf_mountpoint * mountpoint,
|
||||
char const * option)
|
||||
{
|
||||
if ((mountpoint->options.size + 1) >= mountpoint->options.capacity)
|
||||
{
|
||||
mountpoint->options.capacity *= 2;
|
||||
mountpoint->options.items = realloc(mountpoint->options.items,
|
||||
sizeof(char*) * mountpoint->options.capacity);
|
||||
}
|
||||
|
||||
mountpoint->options.items[mountpoint->options.size] = strdup(option);
|
||||
mountpoint->options.items[mountpoint->options.size + 1] = NULL;
|
||||
mountpoint->options.size++;
|
||||
}
|
||||
|
@ -3,20 +3,41 @@
|
||||
|
||||
#include "webfuse/mountpoint.h"
|
||||
|
||||
#ifndef __cplusplus
|
||||
#include <stddef.h>
|
||||
#else
|
||||
#include <cstddef>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
struct wf_mountoptions
|
||||
{
|
||||
char * * items;
|
||||
size_t size;
|
||||
size_t capacity;
|
||||
};
|
||||
|
||||
struct wf_mountpoint
|
||||
{
|
||||
char * path;
|
||||
void * user_data;
|
||||
wf_mountpoint_userdata_dispose_fn * dispose;
|
||||
struct wf_mountoptions options;
|
||||
};
|
||||
|
||||
extern struct wf_mountpoint *
|
||||
wf_impl_mountpoint_create(
|
||||
char const * path);
|
||||
|
||||
extern void
|
||||
extern void
|
||||
wf_impl_mountpoint_dispose(
|
||||
struct wf_mountpoint * mountpoint);
|
||||
|
||||
extern char const *
|
||||
extern char const *
|
||||
wf_impl_mountpoint_get_path(
|
||||
struct wf_mountpoint const * mountpoint);
|
||||
|
||||
@ -26,6 +47,11 @@ wf_impl_mountpoint_set_userdata(
|
||||
void * user_data,
|
||||
wf_mountpoint_userdata_dispose_fn * dispose);
|
||||
|
||||
extern void
|
||||
wf_impl_mountpoint_add_mountoption(
|
||||
struct wf_mountpoint * mountpoint,
|
||||
char const * option);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user