feat(webfuse): add multiclient support (#23)
* fixes verbosity option when set through command line * adds support for build type and allows to run gdb in container * adds missing toolchain headers to project * renames container macros * adds gdbserver * fixes verbosity option when set through command line * adds support for build type and allows to run gdb in container * adds missing toolchain headers to project * renames container macros * adds gdbserver * removes language settings, which contains alternating values * adds wrapper script to launch gdbserver * fix docker command in wrapper script * fixes run in dind setup * replaces docker's init through dump-init * moves filesystem to session * fixes verbosity option when set through command line * adds support for build type and allows to run gdb in container * renames container macros * adds gdbserver * fixes verbosity option when set through command line * adds support for build type and allows to run gdb in container * renames container macros * adds gdbserver * adds wrapper script to launch gdbserver * fix docker command in wrapper script * fixes run in dind setup * replaces docker's init through dump-init * moves filesystem to session * adds container_of * added dlist * allows multiple clients to connect * removes directory when session is closed * adds dependecy to uuid-dev * allow clients to register filesystems * updates documentation * moves mountpoint handling into filesystem: mountpoints are removed during session cleanup * adds filesystem name/id to request parameters * fixes security issue: add_filesystem did not check name * removes default link, if it is broken * recreates symlink "default", if filesystem is gone * updates documentation * fixes memory leak * makes authentication work .. again * updates provider to support changed protocol * removes execute right of hello.txt * fixes style issues * fixes javascript style issues * fixes flase positive from Flawfinder * fixes some javascript style issues * removes use of PATH_MAX * removes use of GNU extensions in container_of implementation * ignores findings of flawfinder * replaces dlist by slist * removes duplicate implementation of slist (message_queue)pull/27/head
parent
979ff1e689
commit
3a7c064af7
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 5.2 KiB |
@ -0,0 +1,16 @@
|
|||||||
|
@startuml
|
||||||
|
|
||||||
|
salt
|
||||||
|
{
|
||||||
|
{T
|
||||||
|
+ mount_point
|
||||||
|
++ fwupdate
|
||||||
|
+++ default -> 7c029f81-6bdf-4d3c-82dc-26f748164012
|
||||||
|
+++ 7c029f81-6bdf-4d3c-82dc-26f748164012
|
||||||
|
++++ update.raucb
|
||||||
|
+++ f93de23b-4535-4a47-a287-a381b78a11b8
|
||||||
|
++++ update.raucb
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@enduml
|
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef WF_CONTAINER_OF_H
|
||||||
|
#define WF_CONTAINER_OF_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stddef.h>
|
||||||
|
#else
|
||||||
|
#include <cstddef>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define WF_CONTAINER_OF(pointer, type, member) \
|
||||||
|
(type *) (((char *) pointer) - offsetof(type, member))
|
||||||
|
|
||||||
|
#endif
|
@ -1,63 +1,17 @@
|
|||||||
#include "webfuse/core/message_queue.h"
|
#include "webfuse/core/message_queue.h"
|
||||||
#include "webfuse/core/message.h"
|
#include "webfuse/core/message.h"
|
||||||
|
#include "webfuse/core/container_of.h"
|
||||||
void wf_message_queue_init(
|
|
||||||
struct wf_message_queue * queue)
|
|
||||||
{
|
|
||||||
queue->first = NULL;
|
|
||||||
queue->last = NULL;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void wf_message_queue_cleanup(
|
void wf_message_queue_cleanup(
|
||||||
struct wf_message_queue * queue)
|
struct wf_slist * queue)
|
||||||
{
|
{
|
||||||
struct wf_message * message = queue->first;
|
struct wf_slist_item * item = queue->first;
|
||||||
while (NULL != message)
|
while (NULL != item)
|
||||||
{
|
{
|
||||||
struct wf_message * next = message->next;
|
struct wf_slist_item * next = item->next;
|
||||||
|
struct wf_message * message = WF_CONTAINER_OF(item, struct wf_message, item);
|
||||||
wf_message_dispose(message);
|
wf_message_dispose(message);
|
||||||
message = next;
|
item = next;
|
||||||
}
|
|
||||||
wf_message_queue_init(queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wf_message_queue_empty(
|
|
||||||
struct wf_message_queue * queue)
|
|
||||||
{
|
|
||||||
return (NULL == queue->first);
|
|
||||||
}
|
}
|
||||||
|
wf_slist_init(queue);
|
||||||
void wf_message_queue_push(
|
|
||||||
struct wf_message_queue * queue,
|
|
||||||
struct wf_message * message)
|
|
||||||
{
|
|
||||||
message->next = NULL;
|
|
||||||
|
|
||||||
if (NULL != queue->last)
|
|
||||||
{
|
|
||||||
queue->last->next = message;
|
|
||||||
queue->last = message;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
queue->first = message;
|
|
||||||
queue->last = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wf_message * wf_message_queue_pop(
|
|
||||||
struct wf_message_queue * queue)
|
|
||||||
{
|
|
||||||
struct wf_message * const result = queue->first;
|
|
||||||
if (NULL != result)
|
|
||||||
{
|
|
||||||
queue->first = queue->first->next;
|
|
||||||
if (NULL == queue->first)
|
|
||||||
{
|
|
||||||
queue->last = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,77 @@
|
|||||||
|
#include "webfuse/core/slist.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
void wf_slist_init(
|
||||||
|
struct wf_slist * list)
|
||||||
|
{
|
||||||
|
list->first = NULL;
|
||||||
|
list->last = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wf_slist_empty(
|
||||||
|
struct wf_slist * list)
|
||||||
|
{
|
||||||
|
return (NULL == list->first);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wf_slist_append(
|
||||||
|
struct wf_slist * list,
|
||||||
|
struct wf_slist_item * item)
|
||||||
|
{
|
||||||
|
item->next = NULL;
|
||||||
|
|
||||||
|
if (NULL != list->last)
|
||||||
|
{
|
||||||
|
list->last->next = item;
|
||||||
|
list->last = item;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list->first = item;
|
||||||
|
list->last = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_slist_item * wf_slist_remove_first(
|
||||||
|
struct wf_slist * list)
|
||||||
|
{
|
||||||
|
struct wf_slist_item * const result = list->first;
|
||||||
|
if (NULL != result)
|
||||||
|
{
|
||||||
|
list->first = list->first->next;
|
||||||
|
if (NULL == list->first)
|
||||||
|
{
|
||||||
|
list->last = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wf_slist_item * wf_slist_remove_after(
|
||||||
|
struct wf_slist * list,
|
||||||
|
struct wf_slist_item * prev)
|
||||||
|
{
|
||||||
|
struct wf_slist_item * result = NULL;
|
||||||
|
|
||||||
|
if (NULL != prev)
|
||||||
|
{
|
||||||
|
result = prev->next;
|
||||||
|
if ((NULL != result) && (NULL != result->next))
|
||||||
|
{
|
||||||
|
prev->next = result->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list->last = prev;
|
||||||
|
prev->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = wf_slist_remove_first(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
#ifndef WF_SLIST_H
|
||||||
|
#define WF_SLIST_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdbool.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct wf_slist_item
|
||||||
|
{
|
||||||
|
struct wf_slist_item * next;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct wf_slist
|
||||||
|
{
|
||||||
|
struct wf_slist_item * first;
|
||||||
|
struct wf_slist_item * last;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void wf_slist_init(
|
||||||
|
struct wf_slist * list);
|
||||||
|
|
||||||
|
extern bool wf_slist_empty(
|
||||||
|
struct wf_slist * list);
|
||||||
|
|
||||||
|
extern void wf_slist_append(
|
||||||
|
struct wf_slist * list,
|
||||||
|
struct wf_slist_item * item);
|
||||||
|
|
||||||
|
extern struct wf_slist_item * wf_slist_remove_first(
|
||||||
|
struct wf_slist * list);
|
||||||
|
|
||||||
|
extern struct wf_slist_item * wf_slist_remove_after(
|
||||||
|
struct wf_slist * list,
|
||||||
|
struct wf_slist_item * prev);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,35 @@
|
|||||||
|
#include "webfuse/core/string.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
char * wf_create_string(char const * format, ...)
|
||||||
|
{
|
||||||
|
char * result = NULL;
|
||||||
|
|
||||||
|
va_list measure_args;
|
||||||
|
va_start(measure_args, format);
|
||||||
|
char buffer;
|
||||||
|
int needed = vsnprintf(&buffer, 1, format, measure_args); /* Flawfinder: ignore */
|
||||||
|
va_end(measure_args);
|
||||||
|
|
||||||
|
if (0 <= needed)
|
||||||
|
{
|
||||||
|
result = malloc(needed + 1);
|
||||||
|
if (NULL != result)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, format);
|
||||||
|
int count = vsnprintf(result, needed + 1, format, args); /* Flawfinder: ignore */
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if ((count < 0) || (needed < count))
|
||||||
|
{
|
||||||
|
free(result);
|
||||||
|
result = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef WF_CORE_STRING_H
|
||||||
|
#define WF_CORE_STRING_H
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#include <stdarg.h>
|
||||||
|
#else
|
||||||
|
#include <cstdarg>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern char * wf_create_string(char const * format, ...);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,29 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "webfuse/core/container_of.h"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
|
||||||
|
struct MyStruct
|
||||||
|
{
|
||||||
|
int first;
|
||||||
|
int second;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ContainerOf, FirstMember)
|
||||||
|
{
|
||||||
|
MyStruct my_struct = {23, 42};
|
||||||
|
|
||||||
|
int * first = &my_struct.first;
|
||||||
|
ASSERT_EQ(&my_struct, WF_CONTAINER_OF(first, MyStruct, first));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(ContainerOf, SecondMember)
|
||||||
|
{
|
||||||
|
MyStruct my_struct = {23, 42};
|
||||||
|
|
||||||
|
int * second = &my_struct.second;
|
||||||
|
ASSERT_EQ(&my_struct, WF_CONTAINER_OF(second, MyStruct, second));
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "webfuse/core/slist.h"
|
||||||
|
|
||||||
|
TEST(wf_slist_remove_after, RemoveFirst)
|
||||||
|
{
|
||||||
|
struct wf_slist list;
|
||||||
|
struct wf_slist_item item[10];
|
||||||
|
|
||||||
|
wf_slist_init(&list);
|
||||||
|
wf_slist_append(&list, &item[0]);
|
||||||
|
|
||||||
|
wf_slist_item * removed = wf_slist_remove_after(&list, NULL);
|
||||||
|
ASSERT_TRUE(wf_slist_empty(&list));
|
||||||
|
ASSERT_EQ(nullptr, list.first);
|
||||||
|
ASSERT_EQ(nullptr, list.last);
|
||||||
|
ASSERT_EQ(&item[0], removed);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_slist_remove_after, RemoveLast)
|
||||||
|
{
|
||||||
|
struct wf_slist list;
|
||||||
|
struct wf_slist_item item[10];
|
||||||
|
|
||||||
|
wf_slist_init(&list);
|
||||||
|
wf_slist_append(&list, &item[0]);
|
||||||
|
wf_slist_append(&list, &item[1]);
|
||||||
|
wf_slist_append(&list, &item[2]);
|
||||||
|
|
||||||
|
wf_slist_item * removed = wf_slist_remove_after(&list, &item[1]);
|
||||||
|
ASSERT_FALSE(wf_slist_empty(&list));
|
||||||
|
ASSERT_EQ(&item[0], list.first);
|
||||||
|
ASSERT_EQ(&item[1], list.last);
|
||||||
|
ASSERT_EQ(nullptr, item[1].next);
|
||||||
|
ASSERT_EQ(&item[2], removed);
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "webfuse/core/string.h"
|
||||||
|
|
||||||
|
TEST(wf_string_create, Default)
|
||||||
|
{
|
||||||
|
char * value = wf_create_string("test %s/%d", "hello", 42);
|
||||||
|
ASSERT_STREQ("test hello/42", value);
|
||||||
|
free(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(wf_string_create, EmptyString)
|
||||||
|
{
|
||||||
|
char * value = wf_create_string("");
|
||||||
|
ASSERT_STREQ("", value);
|
||||||
|
free(value);
|
||||||
|
}
|
Loading…
Reference in new issue