mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
reorganized project: prepared to extract common functionality
This commit is contained in:
43
lib/wsfs/provider/operation/close.c
Normal file
43
lib/wsfs/provider/operation/close.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "wsfs/provider/operation/close_intern.h"
|
||||
#include <limits.h>
|
||||
#include "wsfs/util.h"
|
||||
|
||||
void wsfsp_close(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int WSFS_UNUSED_PARAM(id))
|
||||
{
|
||||
size_t const param_count = json_array_size(params);
|
||||
if (3 == param_count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 0);
|
||||
json_t * handle_holder = json_array_get(params, 1);
|
||||
json_t * flags_holder = json_array_get(params, 2);
|
||||
|
||||
if (json_is_integer(inode_holder) &&
|
||||
json_is_integer(handle_holder) &&
|
||||
json_is_integer(flags_holder))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
uint32_t handle = (uint32_t) (json_integer_value(handle_holder) & UINT32_MAX);
|
||||
int flags = json_integer_value(flags_holder);
|
||||
|
||||
context->provider->close(inode, handle, flags, context->user_data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void wsfsp_close_default(
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
int flags,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) handle;
|
||||
(void) flags;
|
||||
(void) user_data;
|
||||
|
||||
// empty
|
||||
}
|
||||
27
lib/wsfs/provider/operation/close_intern.h
Normal file
27
lib/wsfs/provider/operation/close_intern.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef WSFSP_OPERATION_CLOSE_INTERN_H
|
||||
#define WSFSP_OPERATION_CLOSE_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/close.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_close(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_close_default(
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
int flags,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
19
lib/wsfs/provider/operation/error.c
Normal file
19
lib/wsfs/provider/operation/error.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
#include <jansson.h>
|
||||
#include "wsfs/provider/request.h"
|
||||
|
||||
void wsfsp_respond_error(
|
||||
struct wsfsp_request * request,
|
||||
int status)
|
||||
{
|
||||
json_t * response = json_object();
|
||||
json_t * error = json_object();
|
||||
json_object_set_new(error, "code", json_integer(status));
|
||||
json_object_set_new(response, "error", error);
|
||||
json_object_set_new(response, "id", json_integer(request->id));
|
||||
|
||||
request->respond(response, request->user_data);
|
||||
|
||||
json_decref(response);
|
||||
wsfsp_request_dispose(request);
|
||||
}
|
||||
46
lib/wsfs/provider/operation/getattr.c
Normal file
46
lib/wsfs/provider/operation/getattr.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "wsfs/provider/operation/getattr_intern.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
||||
|
||||
void wsfsp_getattr(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
size_t const count = json_array_size(params);
|
||||
if (1 == count)
|
||||
{
|
||||
json_t * inode_holder = json_array_get(params, 0);
|
||||
|
||||
if ((NULL != inode_holder) && (json_is_integer(inode_holder)))
|
||||
{
|
||||
ino_t inode = (ino_t) json_integer_value(inode_holder);
|
||||
struct wsfsp_request * request = wsfsp_request_create(context->request, id);
|
||||
|
||||
context->provider->getattr(request, inode, context->user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wsfsp_getattr_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
}
|
||||
|
||||
void wsfsp_respond_getattr(
|
||||
struct wsfsp_request * request,
|
||||
struct stat const * stat)
|
||||
{
|
||||
(void) request;
|
||||
(void) stat;
|
||||
|
||||
// ToDo: implement me
|
||||
}
|
||||
26
lib/wsfs/provider/operation/getattr_intern.h
Normal file
26
lib/wsfs/provider/operation/getattr_intern.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef WSFSP_OPERATION_GETATTR_INTERN_H
|
||||
#define WSFSP_OPERATION_GETATTR_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/getattr.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_getattr(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_getattr_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
38
lib/wsfs/provider/operation/lookup.c
Normal file
38
lib/wsfs/provider/operation/lookup.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "wsfs/provider/operation/lookup_intern.h"
|
||||
#include <stdio.h>
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
||||
void wsfsp_lookup(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
|
||||
puts("lookup");
|
||||
}
|
||||
|
||||
void wsfsp_respond_lookup(
|
||||
struct wsfsp_request * request,
|
||||
struct stat const * stat)
|
||||
{
|
||||
(void) request;
|
||||
(void) stat;
|
||||
|
||||
}
|
||||
|
||||
void wsfsp_lookup_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t parent,
|
||||
char const * name,
|
||||
void * user_data)
|
||||
{
|
||||
(void) parent;
|
||||
(void) name;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
}
|
||||
|
||||
27
lib/wsfs/provider/operation/lookup_intern.h
Normal file
27
lib/wsfs/provider/operation/lookup_intern.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef WSFSP_OPERATION_LOOKUP_INTERN_H
|
||||
#define WSFSP_OPERATION_LOOKUP_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/lookup.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_lookup(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_lookup_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t parent,
|
||||
char const * name,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
38
lib/wsfs/provider/operation/open.c
Normal file
38
lib/wsfs/provider/operation/open.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "wsfs/provider/operation/open_intern.h"
|
||||
#include <stdio.h>
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
||||
void wsfsp_open(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
|
||||
puts("open");
|
||||
}
|
||||
|
||||
void wsfsp_open_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
int flags,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) flags;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
}
|
||||
|
||||
void wsfsp_respond_open(
|
||||
struct wsfsp_request * request,
|
||||
uint32_t handle)
|
||||
{
|
||||
(void) request;
|
||||
(void) handle;
|
||||
|
||||
// ToDo: implement me
|
||||
}
|
||||
27
lib/wsfs/provider/operation/open_intern.h
Normal file
27
lib/wsfs/provider/operation/open_intern.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef WSFSP_OPERATION_OPEN_INTERN_H
|
||||
#define WSFSP_OPERATION_OPEN_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/open.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_open(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_open_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
int flags,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
42
lib/wsfs/provider/operation/read.c
Normal file
42
lib/wsfs/provider/operation/read.c
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "wsfs/provider/operation/read_intern.h"
|
||||
#include <stdio.h>
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
||||
void wsfsp_read(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
|
||||
puts("read");
|
||||
}
|
||||
|
||||
void wsfsp_read_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
size_t offset,
|
||||
size_t length,
|
||||
void * user_data)
|
||||
{
|
||||
(void) inode;
|
||||
(void) handle;
|
||||
(void) offset;
|
||||
(void) length;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
}
|
||||
|
||||
void wsfsp_respond_read(
|
||||
struct wsfsp_request * request,
|
||||
char const * data,
|
||||
size_t length)
|
||||
{
|
||||
(void) request;
|
||||
(void) data;
|
||||
(void) length;
|
||||
}
|
||||
29
lib/wsfs/provider/operation/read_intern.h
Normal file
29
lib/wsfs/provider/operation/read_intern.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef WSFSP_OPERATION_READ_INTERN_H
|
||||
#define WSFSP_OPERATION_READ_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/read.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_read(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_read_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
size_t offset,
|
||||
size_t length,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
37
lib/wsfs/provider/operation/readdir.c
Normal file
37
lib/wsfs/provider/operation/readdir.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "wsfs/provider/operation/readdir_intern.h"
|
||||
#include <stdio.h>
|
||||
#include "wsfs/provider/operation/error.h"
|
||||
|
||||
void wsfsp_readdir(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id)
|
||||
{
|
||||
(void) context;
|
||||
(void) params;
|
||||
(void) id;
|
||||
|
||||
puts("readdir");
|
||||
}
|
||||
|
||||
void wsfsp_readdir_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t directory,
|
||||
void * user_data)
|
||||
{
|
||||
(void) directory;
|
||||
(void) user_data;
|
||||
|
||||
wsfsp_respond_error(request, -1);
|
||||
}
|
||||
|
||||
void wsfsp_respond_readdir(
|
||||
struct wsfsp_request * request,
|
||||
struct wsfsp_dirbuffer * dirbuffer)
|
||||
{
|
||||
(void) request;
|
||||
(void) dirbuffer;
|
||||
|
||||
// ToDo: implement me
|
||||
}
|
||||
|
||||
26
lib/wsfs/provider/operation/readdir_intern.h
Normal file
26
lib/wsfs/provider/operation/readdir_intern.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef WSFSP_OPERATION_READDIR_INTERN_H
|
||||
#define WSFSP_OPERATION_READDIR_INTERN_H
|
||||
|
||||
#include "wsfs/provider/operation/readdir.h"
|
||||
#include "wsfs/provider/provider_intern.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
extern void wsfsp_readdir(
|
||||
struct wsfsp_invokation_context * context,
|
||||
json_t * params,
|
||||
int id);
|
||||
|
||||
extern void wsfsp_readdir_default(
|
||||
struct wsfsp_request * request,
|
||||
ino_t directory,
|
||||
void * user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user