1
0
mirror of https://github.com/falk-werner/webfuse synced 2024-10-27 20:34:10 +00:00
falk-werner_webfuse/src/wsfs/operation/open.c

43 lines
950 B
C
Raw Normal View History

2019-01-29 22:11:46 +00:00
#include "wsfs/operations.h"
2019-02-03 18:10:05 +00:00
#include <errno.h>
2019-01-29 22:11:46 +00:00
#include <jansson.h>
2019-02-03 18:10:05 +00:00
2019-01-29 22:11:46 +00:00
#include "wsfs/jsonrpc.h"
2019-02-03 18:10:05 +00:00
#include "wsfs/util.h"
2019-01-29 22:11:46 +00:00
2019-02-03 18:10:05 +00:00
void wsfs_operation_open(
fuse_req_t request,
fuse_ino_t inode,
2019-01-29 22:11:46 +00:00
struct fuse_file_info * file_info)
{
2019-02-03 18:10:05 +00:00
struct wsfs_operations_context * user_data = fuse_req_userdata(request);
struct wsfs_jsonrpc * rpc = user_data->rpc;
2019-01-29 22:11:46 +00:00
json_t * result = NULL;
2019-02-03 18:10:05 +00:00
wsfs_status status = wsfs_jsonrpc_invoke(rpc, &result, "open", "ii", inode, file_info->flags);
2019-01-29 22:11:46 +00:00
if (NULL != result)
{
2019-01-29 22:47:08 +00:00
json_t * handle_holder = json_object_get(result, "handle");
if ((NULL != handle_holder) && (json_is_integer(handle_holder)))
{
file_info->fh = json_integer_value(handle_holder);
}
else
{
status = WSFS_BAD_FORMAT;
}
2019-01-29 22:11:46 +00:00
json_decref(result);
}
2019-02-03 18:10:05 +00:00
if (WSFS_GOOD == status)
{
fuse_reply_open(request, file_info);
}
else
{
fuse_reply_err(request, ENOENT);
}
2019-01-29 22:11:46 +00:00
}