mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
added implementation of getattr stub
This commit is contained in:
parent
3bc041877a
commit
c7c28416db
@ -103,6 +103,7 @@ set(WSFS_PROVIDER_SOURCES
|
|||||||
lib/wsfsp/client.c
|
lib/wsfsp/client.c
|
||||||
lib/wsfsp/client_protocol.c
|
lib/wsfsp/client_protocol.c
|
||||||
lib/wsfsp/provider.c
|
lib/wsfsp/provider.c
|
||||||
|
lib/wsfsp/request.c
|
||||||
lib/wsfsp/operation/error.c
|
lib/wsfsp/operation/error.c
|
||||||
lib/wsfsp/operation/lookup.c
|
lib/wsfsp/operation/lookup.c
|
||||||
lib/wsfsp/operation/getattr.c
|
lib/wsfsp/operation/getattr.c
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
#include "wsfsp/operation/error.h"
|
#include "wsfsp/operation/error.h"
|
||||||
|
#include <jansson.h>
|
||||||
|
#include "wsfsp/request.h"
|
||||||
|
|
||||||
void wsfsp_respond_error(
|
void wsfsp_respond_error(
|
||||||
struct wsfsp_request * request,
|
struct wsfsp_request * request,
|
||||||
int status)
|
int status)
|
||||||
{
|
{
|
||||||
(void) request;
|
json_t * response = json_object();
|
||||||
(void) status;
|
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));
|
||||||
|
|
||||||
// ToDo: implement me
|
request->respond(response, request->user_data);
|
||||||
|
|
||||||
|
json_decref(response);
|
||||||
|
wsfsp_request_dispose(request);
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,19 @@ void wsfsp_getattr(
|
|||||||
json_t * params,
|
json_t * params,
|
||||||
int id)
|
int id)
|
||||||
{
|
{
|
||||||
(void) context;
|
size_t const count = json_array_size(params);
|
||||||
(void) params;
|
if (1 == count)
|
||||||
(void) id;
|
{
|
||||||
|
json_t * inode_holder = json_array_get(params, 0);
|
||||||
|
|
||||||
puts("getattr");
|
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(
|
void wsfsp_getattr_default(
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#define WSFSP_PROVIDER_INTERN_H
|
#define WSFSP_PROVIDER_INTERN_H
|
||||||
|
|
||||||
#include "wsfsp/provider.h"
|
#include "wsfsp/provider.h"
|
||||||
|
#include "wsfsp/request.h"
|
||||||
|
|
||||||
#include <jansson.h>
|
#include <jansson.h>
|
||||||
|
|
||||||
struct wsfsp_invokation_context
|
struct wsfsp_invokation_context
|
||||||
|
24
lib/wsfsp/request.c
Normal file
24
lib/wsfsp/request.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include "wsfsp/request.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
struct wsfsp_request * wsfsp_request_create(
|
||||||
|
struct wsfsp_request * prototype,
|
||||||
|
int id)
|
||||||
|
{
|
||||||
|
struct wsfsp_request * request = malloc(sizeof(struct wsfsp_request));
|
||||||
|
if (NULL != request)
|
||||||
|
{
|
||||||
|
request->respond = prototype->respond;
|
||||||
|
request->user_data = prototype->user_data;
|
||||||
|
request->id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wsfsp_request_dispose(
|
||||||
|
struct wsfsp_request * request)
|
||||||
|
{
|
||||||
|
free(request);
|
||||||
|
}
|
@ -12,7 +12,24 @@ struct wsfsp_request
|
|||||||
{
|
{
|
||||||
wsfsp_request_respond_fn * respond;
|
wsfsp_request_respond_fn * respond;
|
||||||
void * user_data;
|
void * user_data;
|
||||||
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern struct wsfsp_request * wsfsp_request_create(
|
||||||
|
struct wsfsp_request * prototype,
|
||||||
|
int id);
|
||||||
|
|
||||||
|
extern void wsfsp_request_dispose(
|
||||||
|
struct wsfsp_request * request);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user