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

makes wsfs_status public (usable in provider example)

This commit is contained in:
Falk Werner 2019-03-04 19:19:04 +01:00
parent fff6d54046
commit 2781aadf55
15 changed files with 25 additions and 82 deletions

View File

@ -46,12 +46,14 @@ set(EXTRA_CFLAGS
set(WSFS_COMMON_SOURCES
lib/wsfs/message.c
lib/wsfs/message_queue.c
lib/wsfs/status.c
)
install(FILES include/wsfs/status.h DESTINATION include/wsfs)
# libwsfs-adapter
set(WSFS_ADAPTER_SOURCES
lib/wsfs/adapter/status.c
lib/wsfs/adapter/filesystem.c
lib/wsfs/adapter/server.c
lib/wsfs/adapter/time/timepoint.c

View File

@ -102,7 +102,7 @@ static void fs_lookup(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
}
@ -124,7 +124,7 @@ static void fs_getattr(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
}
@ -156,7 +156,7 @@ static void fs_readdir(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
}
@ -177,12 +177,12 @@ static void fs_open(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOACCESS);
}
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
}
@ -214,12 +214,12 @@ static void fs_read(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD);
}
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
}

View File

@ -2,6 +2,7 @@
#define WSFSP_OPERATION_ERROR_H
#include "wsfs/provider/api.h"
#include "wsfs/status.h"
struct wsfsp_request;
@ -12,7 +13,7 @@ extern "C"
extern WSFSP_API void wsfsp_respond_error(
struct wsfsp_request * request,
int status);
wsfs_status status);
#ifdef __cplusplus
}

View File

@ -1,6 +1,8 @@
#ifndef WSFS_ADAPTER_H
#define WSFS_ADAPTER_H
#include <wsfs/status.h>
#include <wsfs/adapter/api.h>
#include <wsfs/adapter/server.h>
#include <wsfs/adapter/server_config.h>

View File

@ -1,6 +1,8 @@
#ifndef WSFS_PROVIDER_H
#define WSFS_PROVIDER_H
#include <wsfs/status.h>
#include <wsfs/provider/api.h>
#include <wsfs/provider/client.h>
#include <wsfs/provider/client_protocol.h>

View File

@ -6,7 +6,7 @@
#endif
#include <jansson.h>
#include "wsfs/adapter/status.h"
#include "wsfs/status.h"
typedef bool wsfs_jsonrpc_method_invoke_fn(

View File

@ -9,7 +9,7 @@ using std::size_t;
#endif
#include <jansson.h>
#include "wsfs/adapter/status.h"
#include "wsfs/status.h"
struct wsfs_jsonrpc_response
{

View File

@ -6,7 +6,7 @@
#include "wsfs/adapter/jsonrpc/server.h"
#include "wsfs/util.h"
#include "wsfs/adapter/status.h"
#include "wsfs/status.h"
static void wsfs_operation_open_finished(
void * user_data,

View File

@ -1,34 +0,0 @@
#include "wsfs/adapter/status.h"
#include <errno.h>
int wsfs_status_to_rc(wsfs_status status)
{
switch(status)
{
case WSFS_GOOD: return 0;
case WSFS_BAD_NOTIMPLEMENTED: return -ENOSYS;
case WSFS_BAD_TIMEOUT: return -ETIMEDOUT;
case WSFS_BAD_BUSY: return -ENOENT;
case WSFS_BAD_FORMAT: return -ENOENT;
case WSFS_BAD_NOENTRY: return -ENOENT;
case WSFS_BAD_NOACCESS: return -EACCES;
default: return -ENOENT;
}
}
char const * wsfs_status_tostring(wsfs_status status)
{
switch(status)
{
case WSFS_GOOD: return "Good";
case WSFS_BAD: return "Bad";
case WSFS_BAD_NOTIMPLEMENTED: return "Bad (not implelemted)";
case WSFS_BAD_TIMEOUT: return "Bad (timeout)";
case WSFS_BAD_BUSY: return "Bad (busy)";
case WSFS_BAD_FORMAT: return "Bad (format)";
case WSFS_BAD_NOENTRY: return "Bad (no entry)";
case WSFS_BAD_NOACCESS: return "Bad (no access)";
default: return "Bad (unknown)";
}
}

View File

@ -1,30 +0,0 @@
#ifndef WSFS_ADAPTER_STATUS_H
#define WSFS_ADAPTER_STATUS_H
#define WSFS_GOOD 0
#define WSFS_BAD 1
#define WSFS_BAD_NOTIMPLEMENTED 2
#define WSFS_BAD_TIMEOUT 3
#define WSFS_BAD_BUSY 4
#define WSFS_BAD_FORMAT 5
#define WSFS_BAD_NOENTRY 101
#define WSFS_BAD_NOACCESS 102
typedef int wsfs_status;
#ifdef __cplusplus
extern "C" {
#endif
extern int wsfs_status_to_rc(wsfs_status status);
extern char const * wsfs_status_tostring(wsfs_status status);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -62,6 +62,6 @@ void wsfsp_lookup_default(
char const * WSFS_UNUSED_PARAM(name),
void * WSFS_UNUSED_PARAM(user_data))
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}

View File

@ -33,7 +33,7 @@ void wsfsp_open_default(
int WSFS_UNUSED_PARAM(flags),
void * WSFS_UNUSED_PARAM(user_data))
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
void wsfsp_respond_open(

View File

@ -43,7 +43,7 @@ void wsfsp_read_default(
size_t WSFS_UNUSED_PARAM(length),
void * WSFS_UNUSED_PARAM(user_data))
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
void wsfsp_respond_read(
@ -69,7 +69,7 @@ void wsfsp_respond_read(
}
else
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD);
}
}
else

View File

@ -29,7 +29,7 @@ void wsfsp_readdir_default(
ino_t WSFS_UNUSED_PARAM(directory),
void * WSFS_UNUSED_PARAM(user_data))
{
wsfsp_respond_error(request, -1);
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
}
void wsfsp_respond_readdir(

View File

@ -40,7 +40,7 @@ extern void wsfsp_respond(
void wsfsp_respond_error(
struct wsfsp_request * request,
int status)
wsfs_status status)
{
json_t * response = json_object();
json_t * error = json_object();