1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00

moved fuse_main to operations

This commit is contained in:
Falk Werner 2019-02-02 09:37:18 +01:00
parent 21fbc199f6
commit 0c5d66e434
4 changed files with 20 additions and 8 deletions

View File

@ -132,9 +132,6 @@ int main(int argc, char * argv[])
int result = parse_arguments(argc, argv, &args); int result = parse_arguments(argc, argv, &args);
struct fuse_operations operations;
wsfs_operations_init(&operations);
if (!args.show_help) if (!args.show_help)
{ {
struct wsfs_server * server = wsfs_server_create(&args.config); struct wsfs_server * server = wsfs_server_create(&args.config);
@ -143,8 +140,7 @@ int main(int argc, char * argv[])
wsfs_server_start(server); wsfs_server_start(server);
struct wsfs_jsonrpc * const rpc = wsfs_server_get_jsonrpc_service(server); struct wsfs_jsonrpc * const rpc = wsfs_server_get_jsonrpc_service(server);
char * fuse_args[] = { "-s", "-f", args.mount_point, NULL }; result = wsfs_operations_loop(args.mount_point, rpc);
result = fuse_main(3, fuse_args, &operations, rpc);
wsfs_server_dispose(server); wsfs_server_dispose(server);
} }
else else

View File

@ -7,6 +7,7 @@ extern "C" {
#define FUSE_USE_VERSION 31 #define FUSE_USE_VERSION 31
#include <fuse.h> #include <fuse.h>
#include <fuse_lowlevel.h>
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -15,7 +15,7 @@ static void* wsfs_operation_init(
return context->private_data; return context->private_data;
} }
void wsfs_operations_init( static void wsfs_operations_init(
struct fuse_operations * operations) struct fuse_operations * operations)
{ {
memset(operations, 0, sizeof(struct fuse_operations)); memset(operations, 0, sizeof(struct fuse_operations));
@ -27,3 +27,15 @@ void wsfs_operations_init(
operations->read = &wsfs_operation_read; operations->read = &wsfs_operation_read;
} }
int wsfs_operations_loop(
char * mount_point,
struct wsfs_jsonrpc * rpc)
{
struct fuse_operations operations;
wsfs_operations_init(&operations);
char * fuse_args[] = { "app", "-s", "-f", mount_point, NULL };
int const result = fuse_main(4, fuse_args, &operations, rpc);
return result;
}

View File

@ -3,12 +3,15 @@
#include "wsfs/fuse_wrapper.h" #include "wsfs/fuse_wrapper.h"
struct wsfs_jsonrpc;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern void wsfs_operations_init( extern int wsfs_operations_loop(
struct fuse_operations * operations); char * mount_point,
struct wsfs_jsonrpc * rpc);
extern int wsfs_operation_readdir( extern int wsfs_operation_readdir(
char const * path, char const * path,