2019-01-27 02:45:03 +00:00
|
|
|
#include "wsfs/operations.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "wsfs/util.h"
|
2019-01-29 22:11:46 +00:00
|
|
|
#include "wsfs/jsonrpc.h"
|
2019-01-27 02:45:03 +00:00
|
|
|
|
|
|
|
static void* wsfs_operation_init(
|
|
|
|
struct fuse_conn_info * WSFS_UNUSED_PARAM(connection),
|
|
|
|
struct fuse_config * config)
|
|
|
|
{
|
|
|
|
struct fuse_context * const context = fuse_get_context();
|
|
|
|
config->kernel_cache = 1;
|
|
|
|
|
2019-01-29 22:11:46 +00:00
|
|
|
return context->private_data;
|
2019-01-27 11:01:01 +00:00
|
|
|
}
|
|
|
|
|
2019-02-02 08:37:18 +00:00
|
|
|
static void wsfs_operations_init(
|
2019-01-27 02:45:03 +00:00
|
|
|
struct fuse_operations * operations)
|
|
|
|
{
|
|
|
|
memset(operations, 0, sizeof(struct fuse_operations));
|
|
|
|
operations->init = &wsfs_operation_init;
|
|
|
|
operations->getattr = &wsfs_operation_getattr;
|
|
|
|
operations->readdir = &wsfs_operation_readdir;
|
2019-01-27 11:01:01 +00:00
|
|
|
operations->open = &wsfs_operation_open;
|
2019-01-29 22:47:08 +00:00
|
|
|
operations->release = &wsfs_operation_close;
|
2019-01-27 11:01:01 +00:00
|
|
|
operations->read = &wsfs_operation_read;
|
2019-01-27 02:45:03 +00:00
|
|
|
}
|
|
|
|
|
2019-02-02 08:37:18 +00:00
|
|
|
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;
|
|
|
|
}
|
2019-02-02 10:45:38 +00:00
|
|
|
|
|
|
|
int wsfs_operations_loop_ll(
|
|
|
|
char * WSFS_UNUSED_PARAM(mount_point),
|
|
|
|
struct wsfs_jsonrpc * WSFS_UNUSED_PARAM(rpc))
|
|
|
|
{
|
|
|
|
struct fuse_lowlevel_ops operations;
|
|
|
|
memset(&operations, 0, sizeof(struct fuse_lowlevel_ops));
|
|
|
|
operations.lookup = &wsfs_operation_ll_lookup;
|
|
|
|
operations.getattr = &wsfs_operation_ll_getattr;
|
|
|
|
operations.readdir = &wsfs_operation_ll_readdir;
|
|
|
|
operations.open = &wsfs_operation_ll_open;
|
|
|
|
operations.release = &wsfs_operation_ll_close;
|
|
|
|
operations.read = &wsfs_operation_ll_read;
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|