Rename project to ToastyFS
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
Architecture
|
||||
A MouseFS instance is composed by a metadata server, a number
|
||||
A ToastyFS instance is composed by a metadata server, a number
|
||||
of chunk servers, and a number of clients.
|
||||
|
||||
The metadata server stores the full file system hieararchy,
|
||||
|
||||
@@ -17,9 +17,9 @@ OFILES = $(CFILES:.c=.o)
|
||||
|
||||
.PHONY: all clean coverage coverage-report coverage-html
|
||||
|
||||
all: mousefs$(EXT) mousefs_random_test$(EXT) example_client$(EXT) libmousefs.a
|
||||
all: toastyfs$(EXT) toastyfs_random_test$(EXT) example_client$(EXT) libtoastyfs.a
|
||||
|
||||
coverage: mousefs_random_test_coverage$(EXT)
|
||||
coverage: toastyfs_random_test_coverage$(EXT)
|
||||
|
||||
coverage-report:
|
||||
@./scripts/measure_coverage.sh 60
|
||||
@@ -27,35 +27,35 @@ coverage-report:
|
||||
coverage-html:
|
||||
@./scripts/measure_coverage.sh 60 --html
|
||||
|
||||
mousefs$(EXT): $(CFILES) $(HFILES)
|
||||
toastyfs$(EXT): $(CFILES) $(HFILES)
|
||||
gcc -o $@ $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc -DBUILD_SERVER
|
||||
|
||||
mousefs_random_test$(EXT): $(CFILES) $(HFILES)
|
||||
toastyfs_random_test$(EXT): $(CFILES) $(HFILES)
|
||||
gcc -o $@ $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc -DBUILD_TEST
|
||||
|
||||
mousefs_random_test_coverage$(EXT): $(CFILES) $(HFILES)
|
||||
toastyfs_random_test_coverage$(EXT): $(CFILES) $(HFILES)
|
||||
gcc -o $@ $(CFILES) $(COVERAGE_CFLAGS) $(LFLAGS) $(COVERAGE_LFLAGS) -Iinc -DBUILD_TEST
|
||||
|
||||
example_client$(EXT): libmousefs.a
|
||||
gcc -o $@ examples/main.c $(CFLAGS) -lmousefs $(LFLAGS) -Iinc -L.
|
||||
example_client$(EXT): libtoastyfs.a
|
||||
gcc -o $@ examples/main.c $(CFLAGS) -ltoastyfs $(LFLAGS) -Iinc -L.
|
||||
|
||||
%.o: %.c $(HFILES)
|
||||
gcc -c -o $@ $< $(CFLAGS) -Iinc
|
||||
|
||||
libmousefs.a: $(OFILES)
|
||||
libtoastyfs.a: $(OFILES)
|
||||
ar rcs $@ $^
|
||||
|
||||
clean:
|
||||
rm -f \
|
||||
mousefs.exe \
|
||||
mousefs.out \
|
||||
mousefs_random_test.exe \
|
||||
mousefs_random_test.out \
|
||||
mousefs_random_test_coverage.exe \
|
||||
mousefs_random_test_coverage.out \
|
||||
toastyfs.exe \
|
||||
toastyfs.out \
|
||||
toastyfs_random_test.exe \
|
||||
toastyfs_random_test.out \
|
||||
toastyfs_random_test_coverage.exe \
|
||||
toastyfs_random_test_coverage.out \
|
||||
example_client.exe \
|
||||
example_client.out \
|
||||
libmousefs.a \
|
||||
libtoastyfs.a \
|
||||
src/*.o \
|
||||
src/*.gcda \
|
||||
src/*.gcno \
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
- Implement proper operation handles that allow users to wait for specific events
|
||||
- Clean up the read operation for clients
|
||||
- Check that the corner case where read and writes go over the length of the file work correctly
|
||||
- Return the number of bytes read or written in the MouseFS_Result struct
|
||||
- Return the number of bytes read or written in the ToastyFS_Result struct
|
||||
- Make parallel uploads/downloads configurable
|
||||
- Recalculate next write locations whenever a write occurs, not at each read
|
||||
- avoid replay attacks
|
||||
|
||||
+14
-14
@@ -1,39 +1,39 @@
|
||||
#include <stddef.h>
|
||||
#include <MouseFS.h>
|
||||
#include <ToastyFS.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
MouseFS *mfs = mousefs_init("127.0.0.1", 8080);
|
||||
if (mfs == NULL)
|
||||
ToastyFS *tfs = toastyfs_init("127.0.0.1", 8080);
|
||||
if (tfs == NULL)
|
||||
return -1;
|
||||
|
||||
if (mousefs_submit_create(mfs, "/my_file_1", -1, false, 1024) < 0) {
|
||||
mousefs_free(mfs);
|
||||
if (toastyfs_submit_create(tfs, "/my_file_1", -1, false, 1024) < 0) {
|
||||
toastyfs_free(tfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mousefs_submit_create(mfs, "/my_file_2", -1, false, 1024) < 0) {
|
||||
mousefs_free(mfs);
|
||||
if (toastyfs_submit_create(tfs, "/my_file_2", -1, false, 1024) < 0) {
|
||||
toastyfs_free(tfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buff_1[] = "This is file 1";
|
||||
if (mousefs_submit_write(mfs, "/my_file_1", -1, 0, buff_1, sizeof(buff_1)-1) < 0) {
|
||||
mousefs_free(mfs);
|
||||
if (toastyfs_submit_write(tfs, "/my_file_1", -1, 0, buff_1, sizeof(buff_1)-1) < 0) {
|
||||
toastyfs_free(tfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buff_2[] = "This is file 2";
|
||||
if (mousefs_submit_write(mfs, "/my_file_1", -1, 0, buff_2, sizeof(buff_2)-1) < 0) {
|
||||
mousefs_free(mfs);
|
||||
if (toastyfs_submit_write(tfs, "/my_file_1", -1, 0, buff_2, sizeof(buff_2)-1) < 0) {
|
||||
toastyfs_free(tfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
MouseFS_Result result;
|
||||
mousefs_wait(mfs, -1, &result, -1);
|
||||
ToastyFS_Result result;
|
||||
toastyfs_wait(tfs, -1, &result, -1);
|
||||
}
|
||||
|
||||
mousefs_free(mfs);
|
||||
toastyfs_free(tfs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef MOUSEFS_INCLUDED
|
||||
#define MOUSEFS_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
typedef struct MouseFS MouseFS;
|
||||
|
||||
typedef struct {
|
||||
char name[128]; // TODO: Implement a proper name length
|
||||
bool is_dir;
|
||||
} MouseFS_Entity;
|
||||
|
||||
typedef enum {
|
||||
MOUSEFS_RESULT_EMPTY,
|
||||
MOUSEFS_RESULT_CREATE_ERROR,
|
||||
MOUSEFS_RESULT_CREATE_SUCCESS,
|
||||
MOUSEFS_RESULT_DELETE_ERROR,
|
||||
MOUSEFS_RESULT_DELETE_SUCCESS,
|
||||
MOUSEFS_RESULT_LIST_ERROR,
|
||||
MOUSEFS_RESULT_LIST_SUCCESS,
|
||||
MOUSEFS_RESULT_READ_ERROR,
|
||||
MOUSEFS_RESULT_READ_SUCCESS,
|
||||
MOUSEFS_RESULT_WRITE_ERROR,
|
||||
MOUSEFS_RESULT_WRITE_SUCCESS,
|
||||
} MouseFS_ResultType;
|
||||
|
||||
typedef struct {
|
||||
|
||||
MouseFS_ResultType type;
|
||||
|
||||
int num_entities;
|
||||
MouseFS_Entity *entities;
|
||||
} MouseFS_Result;
|
||||
|
||||
MouseFS *mousefs_init(char *addr, uint16_t port);
|
||||
void mousefs_free(MouseFS *mfs);
|
||||
void mousefs_wait(MouseFS *mfs, int opidx, MouseFS_Result *result, int timeout);
|
||||
|
||||
bool mousefs_isdone(MouseFS *mfs, int opidx, MouseFS_Result *result);
|
||||
int mousefs_process_events(MouseFS *mfs, void **contexts, struct pollfd *polled, int num_polled);
|
||||
|
||||
int mousefs_submit_create (MouseFS *mfs, char *path, int path_len, bool is_dir, unsigned int chunk_size);
|
||||
int mousefs_submit_delete (MouseFS *mfs, char *path, int path_len);
|
||||
int mousefs_submit_list (MouseFS *mfs, char *path, int path_len);
|
||||
int mousefs_submit_read (MouseFS *mfs, char *path, int path_len, int off, void *dst, int len);
|
||||
int mousefs_submit_write (MouseFS *mfs, char *path, int path_len, int off, void *src, int len);
|
||||
void mousefs_result_free(MouseFS_Result *result);
|
||||
|
||||
#endif // MOUSEFS_INCLUDED
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef TOASTYFS_INCLUDED
|
||||
#define TOASTYFS_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
typedef struct ToastyFS ToastyFS;
|
||||
|
||||
typedef struct {
|
||||
char name[128]; // TODO: Implement a proper name length
|
||||
bool is_dir;
|
||||
} ToastyFS_Entity;
|
||||
|
||||
typedef enum {
|
||||
TOASTYFS_RESULT_EMPTY,
|
||||
TOASTYFS_RESULT_CREATE_ERROR,
|
||||
TOASTYFS_RESULT_CREATE_SUCCESS,
|
||||
TOASTYFS_RESULT_DELETE_ERROR,
|
||||
TOASTYFS_RESULT_DELETE_SUCCESS,
|
||||
TOASTYFS_RESULT_LIST_ERROR,
|
||||
TOASTYFS_RESULT_LIST_SUCCESS,
|
||||
TOASTYFS_RESULT_READ_ERROR,
|
||||
TOASTYFS_RESULT_READ_SUCCESS,
|
||||
TOASTYFS_RESULT_WRITE_ERROR,
|
||||
TOASTYFS_RESULT_WRITE_SUCCESS,
|
||||
} ToastyFS_ResultType;
|
||||
|
||||
typedef struct {
|
||||
|
||||
ToastyFS_ResultType type;
|
||||
|
||||
int num_entities;
|
||||
ToastyFS_Entity *entities;
|
||||
} ToastyFS_Result;
|
||||
|
||||
ToastyFS *toastyfs_init(char *addr, uint16_t port);
|
||||
void toastyfs_free(ToastyFS *tfs);
|
||||
void toastyfs_wait(ToastyFS *tfs, int opidx, ToastyFS_Result *result, int timeout);
|
||||
|
||||
bool toastyfs_isdone(ToastyFS *tfs, int opidx, ToastyFS_Result *result);
|
||||
int toastyfs_process_events(ToastyFS *tfs, void **contexts, struct pollfd *polled, int num_polled);
|
||||
|
||||
int toastyfs_submit_create (ToastyFS *tfs, char *path, int path_len, bool is_dir, unsigned int chunk_size);
|
||||
int toastyfs_submit_delete (ToastyFS *tfs, char *path, int path_len);
|
||||
int toastyfs_submit_list (ToastyFS *tfs, char *path, int path_len);
|
||||
int toastyfs_submit_read (ToastyFS *tfs, char *path, int path_len, int off, void *dst, int len);
|
||||
int toastyfs_submit_write (ToastyFS *tfs, char *path, int path_len, int off, void *src, int len);
|
||||
void toastyfs_result_free(ToastyFS_Result *result);
|
||||
|
||||
#endif // TOASTYFS_INCLUDED
|
||||
@@ -29,7 +29,7 @@ SIMULATION_TIME=${1:-5} # Default to 5 seconds if not specified
|
||||
echo "Running for ${SIMULATION_TIME} seconds..."
|
||||
|
||||
# Run simulation in background and kill it after specified time
|
||||
timeout ${SIMULATION_TIME}s ./mousefs_random_test_coverage.out || true
|
||||
timeout ${SIMULATION_TIME}s ./toastyfs_random_test_coverage.out || true
|
||||
|
||||
# Generate coverage reports
|
||||
echo
|
||||
@@ -44,7 +44,7 @@ TAKEN_BRANCHES=0
|
||||
# Generate gcov reports from the coverage data files
|
||||
for gcda_file in $GCDA_FILES; do
|
||||
# Extract the source file name from the gcda filename
|
||||
# Files are named like: mousefs_random_test_coverage.out-basic.gcda
|
||||
# Files are named like: toastyfs_random_test_coverage.out-basic.gcda
|
||||
basename=$(basename "$gcda_file" .gcda)
|
||||
source_name=${basename#*-} # Remove prefix up to and including '-'
|
||||
|
||||
|
||||
+316
-316
File diff suppressed because it is too large
Load Diff
+29
-29
@@ -34,8 +34,8 @@ int simulation_client_init(SimulationClient *client, int argc, char **argv,
|
||||
uint16_t port;
|
||||
parse_server_addr(argc, argv, &addr, &port);
|
||||
|
||||
client->mfs = mousefs_init(addr, port);
|
||||
if (client->mfs == NULL)
|
||||
client->tfs = toastyfs_init(addr, port);
|
||||
if (client->tfs == NULL)
|
||||
return -1;
|
||||
|
||||
client->num_pending = 0;
|
||||
@@ -43,7 +43,7 @@ int simulation_client_init(SimulationClient *client, int argc, char **argv,
|
||||
printf("Client set up (remote=%s:%d)\n", addr, port);
|
||||
|
||||
*timeout = 0;
|
||||
return mousefs_process_events(client->mfs, contexts, polled, 0);
|
||||
return toastyfs_process_events(client->tfs, contexts, polled, 0);
|
||||
}
|
||||
|
||||
static int random_in_range(int min, int max)
|
||||
@@ -56,73 +56,73 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
struct pollfd *polled, int num_polled, int *timeout)
|
||||
{
|
||||
// Process any pending events from the network and get new poll descriptors
|
||||
num_polled = mousefs_process_events(client->mfs, contexts, polled, num_polled);
|
||||
num_polled = toastyfs_process_events(client->tfs, contexts, polled, num_polled);
|
||||
|
||||
for (int i = 0; i < client->num_pending; i++) {
|
||||
|
||||
MouseFS_Result result;
|
||||
if (!mousefs_isdone(client->mfs, client->pending[i].opidx, &result))
|
||||
ToastyFS_Result result;
|
||||
if (!toastyfs_isdone(client->tfs, client->pending[i].opidx, &result))
|
||||
continue;
|
||||
|
||||
PendingOperation pending = client->pending[i];
|
||||
switch (result.type) {
|
||||
|
||||
case MOUSEFS_RESULT_EMPTY:
|
||||
case TOASTYFS_RESULT_EMPTY:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_CREATE_ERROR:
|
||||
case TOASTYFS_RESULT_CREATE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_CREATE);
|
||||
//printf("[Client] create error\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_CREATE_SUCCESS:
|
||||
case TOASTYFS_RESULT_CREATE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_CREATE);
|
||||
//printf("[Client] create success\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_DELETE_ERROR:
|
||||
case TOASTYFS_RESULT_DELETE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_DELETE);
|
||||
//printf("[Client] delete error\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_DELETE_SUCCESS:
|
||||
case TOASTYFS_RESULT_DELETE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_DELETE);
|
||||
//printf("[Client] delete success\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_LIST_ERROR:
|
||||
case TOASTYFS_RESULT_LIST_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_LIST);
|
||||
//printf("[Client] list error\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_LIST_SUCCESS:
|
||||
case TOASTYFS_RESULT_LIST_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_LIST);
|
||||
//printf("[Client] list success\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_READ_ERROR:
|
||||
case TOASTYFS_RESULT_READ_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_READ);
|
||||
//printf("[Client] read error\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_READ_SUCCESS:
|
||||
case TOASTYFS_RESULT_READ_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_READ);
|
||||
//printf("[Client] read success\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_WRITE_ERROR:
|
||||
case TOASTYFS_RESULT_WRITE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_WRITE);
|
||||
//printf("[Client] write error\n");
|
||||
break;
|
||||
|
||||
case MOUSEFS_RESULT_WRITE_SUCCESS:
|
||||
case TOASTYFS_RESULT_WRITE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_WRITE);
|
||||
//printf("[Client] write success\n");
|
||||
break;
|
||||
}
|
||||
free(pending.ptr);
|
||||
mousefs_result_free(&result);
|
||||
toastyfs_result_free(&result);
|
||||
client->pending[i--] = client->pending[--client->num_pending];
|
||||
}
|
||||
|
||||
@@ -172,8 +172,8 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
case PENDING_OPERATION_CREATE:
|
||||
entry = table[random_in_range(0, table_len-1)];
|
||||
chunk_size = entry.is_dir ? 0 : random_in_range(0, 5000);
|
||||
ret = mousefs_submit_create(
|
||||
client->mfs,
|
||||
ret = toastyfs_submit_create(
|
||||
client->tfs,
|
||||
entry.path,
|
||||
-1,
|
||||
entry.is_dir,
|
||||
@@ -184,8 +184,8 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
|
||||
case PENDING_OPERATION_DELETE:
|
||||
entry = table[random_in_range(0, table_len-1)];
|
||||
ret = mousefs_submit_delete(
|
||||
client->mfs,
|
||||
ret = toastyfs_submit_delete(
|
||||
client->tfs,
|
||||
entry.path,
|
||||
-1
|
||||
);
|
||||
@@ -194,8 +194,8 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
|
||||
case PENDING_OPERATION_LIST:
|
||||
entry = table[random_in_range(0, table_len-1)];
|
||||
ret = mousefs_submit_list(
|
||||
client->mfs,
|
||||
ret = toastyfs_submit_list(
|
||||
client->tfs,
|
||||
entry.path,
|
||||
-1
|
||||
);
|
||||
@@ -208,7 +208,7 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
len = random_in_range(0, 5000);
|
||||
ptr = malloc(len);
|
||||
if (ptr == NULL) assert(0);
|
||||
ret = mousefs_submit_read(client->mfs,
|
||||
ret = toastyfs_submit_read(client->tfs,
|
||||
entry.path,
|
||||
-1,
|
||||
off,
|
||||
@@ -225,8 +225,8 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
ptr = malloc(len);
|
||||
if (ptr == NULL) assert(0);
|
||||
memset(ptr, 'a', len);
|
||||
ret = mousefs_submit_write(
|
||||
client->mfs,
|
||||
ret = toastyfs_submit_write(
|
||||
client->tfs,
|
||||
entry.path,
|
||||
-1,
|
||||
off,
|
||||
@@ -250,12 +250,12 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
*timeout = 10;
|
||||
else
|
||||
*timeout = -1;
|
||||
return mousefs_process_events(client->mfs, contexts, polled, 0);
|
||||
return toastyfs_process_events(client->tfs, contexts, polled, 0);
|
||||
}
|
||||
|
||||
void simulation_client_free(SimulationClient *client)
|
||||
{
|
||||
mousefs_free(client->mfs);
|
||||
toastyfs_free(client->tfs);
|
||||
}
|
||||
|
||||
#endif // BUILD_TEST
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "MouseFS.h"
|
||||
#include "ToastyFS.h"
|
||||
|
||||
#define MAX_PENDING_OPERATION 8
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct {
|
||||
} PendingOperation;
|
||||
|
||||
typedef struct {
|
||||
MouseFS *mfs;
|
||||
ToastyFS *tfs;
|
||||
int num_pending;
|
||||
PendingOperation pending[MAX_PENDING_OPERATION];
|
||||
} SimulationClient;
|
||||
|
||||
Reference in New Issue
Block a user