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

added implemetation of open

This commit is contained in:
Falk Werner 2019-03-03 16:29:02 +01:00
parent 3627ede1b1
commit 519ec3a178
2 changed files with 40 additions and 12 deletions

View File

@ -4,6 +4,9 @@
#include <signal.h> #include <signal.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "wsfs_provider.h" #include "wsfs_provider.h"
enum fs_entry_type enum fs_entry_type
@ -180,13 +183,25 @@ static void fs_open(
int flags, int flags,
void * user_data) void * user_data)
{ {
(void) inode; struct fs * fs = (struct fs*) user_data;
(void) flags;
(void) user_data;
puts("open"); struct fs_entry const * entry = fs_getentry(fs, inode);
if ((NULL != entry) && (FS_FILE == entry->type))
{
if (O_RDONLY == (flags & O_ACCMODE))
{
wsfsp_respond_open(request, 0U);
}
else
{
wsfsp_respond_error(request, -1); wsfsp_respond_error(request, -1);
} }
}
else
{
wsfsp_respond_error(request, -1);
}
}
static void fs_read( static void fs_read(
struct wsfsp_request * request, struct wsfsp_request * request,

View File

@ -1,6 +1,7 @@
#include "wsfs/provider/operation/open_intern.h" #include "wsfs/provider/operation/open_intern.h"
#include <stdio.h> #include <stdio.h>
#include "wsfs/provider/operation/error.h" #include "wsfs/provider/operation/error.h"
#include "wsfs/provider/request.h"
#include "wsfs/util.h" #include "wsfs/util.h"
void wsfsp_open( void wsfsp_open(
@ -8,11 +9,23 @@ void wsfsp_open(
json_t * params, json_t * params,
int id) int id)
{ {
(void) context; size_t const count = json_array_size(params);
(void) params; if (2 == count)
(void) id; {
json_t * inode_holder = json_array_get(params, 0);
json_t * flags_holder = json_array_get(params, 1);
puts("open"); if (json_is_integer(inode_holder) &&
json_is_integer(flags_holder))
{
ino_t inode = (ino_t) json_integer_value(inode_holder);
int flags = (ino_t) json_integer_value(flags_holder);
struct wsfsp_request * request = wsfsp_request_create(context->request, id);
context->provider->open(request, inode, flags, context->user_data);
}
}
} }
void wsfsp_open_default( void wsfsp_open_default(
@ -28,8 +41,8 @@ void wsfsp_respond_open(
struct wsfsp_request * request, struct wsfsp_request * request,
uint32_t handle) uint32_t handle)
{ {
(void) request; json_t * result = json_object();
(void) handle; json_object_set_new(result, "handle", json_integer((int) handle));
// ToDo: implement me wsfsp_respond(request, result);
} }