Rename project from TinyDFS to MouseFS
- Renamed TinyDFS.h to MouseFS.h - Updated all type names: TinyDFS -> MouseFS, TinyDFS_Entity -> MouseFS_Entity, TinyDFS_Result -> MouseFS_Result - Updated all enum values: TINYDFS_RESULT_* -> MOUSEFS_RESULT_* - Updated all function names: tinydfs_* -> mousefs_* - Updated all variable names: tdfs -> mfs - Updated references in all source files, headers, examples, and documentation - Updated Makefile build targets: tinydfs_* -> mousefs_*
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
Architecture
|
||||
A TinyDFS instance is composed by a metadata server, a number
|
||||
A MouseFS 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,
|
||||
|
||||
@@ -14,12 +14,12 @@ HFILES = $(shell find src -name '*.h')
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: tinydfs_server$(EXT) tinydfs_test$(EXT) example_client$(EXT)
|
||||
all: mousefs_server$(EXT) mousefs_test$(EXT) example_client$(EXT)
|
||||
|
||||
tinydfs_server$(EXT): $(CFILES) $(HFILES)
|
||||
mousefs_server$(EXT): $(CFILES) $(HFILES)
|
||||
gcc -o $@ $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc -DBUILD_SERVER
|
||||
|
||||
tinydfs_test$(EXT): $(CFILES) $(HFILES)
|
||||
mousefs_test$(EXT): $(CFILES) $(HFILES)
|
||||
gcc -o $@ $(CFILES) $(CFLAGS) $(LFLAGS) -Iinc -DBUILD_TEST
|
||||
|
||||
example_client$(EXT): examples/main.c $(CFILES) $(HFILES)
|
||||
@@ -27,9 +27,9 @@ example_client$(EXT): examples/main.c $(CFILES) $(HFILES)
|
||||
|
||||
clean:
|
||||
rm \
|
||||
tinydfs_server.exe \
|
||||
tinydfs_server.out \
|
||||
tinydfs_test.exe \
|
||||
tinydfs_test.out \
|
||||
mousefs_server.exe \
|
||||
mousefs_server.out \
|
||||
mousefs_test.exe \
|
||||
mousefs_test.out \
|
||||
example_client.exe \
|
||||
example_client.out
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
- 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
|
||||
- When a client received metadata and starts reading or writing to a chunk server, it should try connecting to all addresses of a chunk servers, not just the first one.
|
||||
- Return the number of bytes read or written in the TinyDFS_Result struct
|
||||
- Return the number of bytes read or written in the MouseFS_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 <TinyDFS.h>
|
||||
#include <MouseFS.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
TinyDFS *tdfs = tinydfs_init("127.0.0.1", 8080);
|
||||
if (tdfs == NULL)
|
||||
MouseFS *mfs = mousefs_init("127.0.0.1", 8080);
|
||||
if (mfs == NULL)
|
||||
return -1;
|
||||
|
||||
if (tinydfs_submit_create(tdfs, "/my_file_1", -1, false, 1024) < 0) {
|
||||
tinydfs_free(tdfs);
|
||||
if (mousefs_submit_create(mfs, "/my_file_1", -1, false, 1024) < 0) {
|
||||
mousefs_free(mfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tinydfs_submit_create(tdfs, "/my_file_2", -1, false, 1024) < 0) {
|
||||
tinydfs_free(tdfs);
|
||||
if (mousefs_submit_create(mfs, "/my_file_2", -1, false, 1024) < 0) {
|
||||
mousefs_free(mfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buff_1[] = "This is file 1";
|
||||
if (tinydfs_submit_write(tdfs, "/my_file_1", -1, 0, buff_1, sizeof(buff_1)-1) < 0) {
|
||||
tinydfs_free(tdfs);
|
||||
if (mousefs_submit_write(mfs, "/my_file_1", -1, 0, buff_1, sizeof(buff_1)-1) < 0) {
|
||||
mousefs_free(mfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
char buff_2[] = "This is file 2";
|
||||
if (tinydfs_submit_write(tdfs, "/my_file_1", -1, 0, buff_2, sizeof(buff_2)-1) < 0) {
|
||||
tinydfs_free(tdfs);
|
||||
if (mousefs_submit_write(mfs, "/my_file_1", -1, 0, buff_2, sizeof(buff_2)-1) < 0) {
|
||||
mousefs_free(mfs);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
TinyDFS_Result result;
|
||||
tinydfs_wait(tdfs, -1, &result, -1);
|
||||
MouseFS_Result result;
|
||||
mousefs_wait(mfs, -1, &result, -1);
|
||||
}
|
||||
|
||||
tinydfs_free(tdfs);
|
||||
mousefs_free(mfs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#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
|
||||
@@ -1,56 +0,0 @@
|
||||
#ifndef TINYDFS_INCLUDED
|
||||
#define TINYDFS_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
typedef struct TinyDFS TinyDFS;
|
||||
|
||||
typedef struct {
|
||||
char name[128]; // TODO: Implement a proper name length
|
||||
bool is_dir;
|
||||
} TinyDFS_Entity;
|
||||
|
||||
typedef enum {
|
||||
TINYDFS_RESULT_EMPTY,
|
||||
TINYDFS_RESULT_CREATE_ERROR,
|
||||
TINYDFS_RESULT_CREATE_SUCCESS,
|
||||
TINYDFS_RESULT_DELETE_ERROR,
|
||||
TINYDFS_RESULT_DELETE_SUCCESS,
|
||||
TINYDFS_RESULT_LIST_ERROR,
|
||||
TINYDFS_RESULT_LIST_SUCCESS,
|
||||
TINYDFS_RESULT_READ_ERROR,
|
||||
TINYDFS_RESULT_READ_SUCCESS,
|
||||
TINYDFS_RESULT_WRITE_ERROR,
|
||||
TINYDFS_RESULT_WRITE_SUCCESS,
|
||||
} TinyDFS_ResultType;
|
||||
|
||||
typedef struct {
|
||||
|
||||
TinyDFS_ResultType type;
|
||||
|
||||
int num_entities;
|
||||
TinyDFS_Entity *entities;
|
||||
} TinyDFS_Result;
|
||||
|
||||
TinyDFS *tinydfs_init(char *addr, uint16_t port);
|
||||
void tinydfs_free(TinyDFS *tdfs);
|
||||
void tinydfs_wait(TinyDFS *tdfs, int opidx, TinyDFS_Result *result, int timeout);
|
||||
|
||||
bool tinydfs_isdone(TinyDFS *tdfs, int opidx, TinyDFS_Result *result);
|
||||
int tinydfs_process_events(TinyDFS *tdfs, void **contexts, struct pollfd *polled, int num_polled);
|
||||
|
||||
int tinydfs_submit_create (TinyDFS *tdfs, char *path, int path_len, bool is_dir, unsigned int chunk_size);
|
||||
int tinydfs_submit_delete (TinyDFS *tdfs, char *path, int path_len);
|
||||
int tinydfs_submit_list (TinyDFS *tdfs, char *path, int path_len);
|
||||
int tinydfs_submit_read (TinyDFS *tdfs, char *path, int path_len, int off, void *dst, int len);
|
||||
int tinydfs_submit_write (TinyDFS *tdfs, char *path, int path_len, int off, void *src, int len);
|
||||
void tinydfs_result_free(TinyDFS_Result *result);
|
||||
|
||||
#endif // TINYDFS_INCLUDED
|
||||
+315
-315
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->tdfs = tinydfs_init(addr, port);
|
||||
if (client->tdfs == NULL)
|
||||
client->mfs = mousefs_init(addr, port);
|
||||
if (client->mfs == 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 tinydfs_process_events(client->tdfs, contexts, polled, 0);
|
||||
return mousefs_process_events(client->mfs, 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 = tinydfs_process_events(client->tdfs, contexts, polled, num_polled);
|
||||
num_polled = mousefs_process_events(client->mfs, contexts, polled, num_polled);
|
||||
|
||||
for (int i = 0; i < client->num_pending; i++) {
|
||||
|
||||
TinyDFS_Result result;
|
||||
if (!tinydfs_isdone(client->tdfs, client->pending[i].opidx, &result))
|
||||
MouseFS_Result result;
|
||||
if (!mousefs_isdone(client->mfs, client->pending[i].opidx, &result))
|
||||
continue;
|
||||
|
||||
PendingOperation pending = client->pending[i];
|
||||
switch (result.type) {
|
||||
|
||||
case TINYDFS_RESULT_EMPTY:
|
||||
case MOUSEFS_RESULT_EMPTY:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_CREATE_ERROR:
|
||||
case MOUSEFS_RESULT_CREATE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_CREATE);
|
||||
//printf("[Client] create error\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_CREATE_SUCCESS:
|
||||
case MOUSEFS_RESULT_CREATE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_CREATE);
|
||||
//printf("[Client] create success\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_DELETE_ERROR:
|
||||
case MOUSEFS_RESULT_DELETE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_DELETE);
|
||||
//printf("[Client] delete error\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_DELETE_SUCCESS:
|
||||
case MOUSEFS_RESULT_DELETE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_DELETE);
|
||||
//printf("[Client] delete success\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_LIST_ERROR:
|
||||
case MOUSEFS_RESULT_LIST_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_LIST);
|
||||
//printf("[Client] list error\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_LIST_SUCCESS:
|
||||
case MOUSEFS_RESULT_LIST_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_LIST);
|
||||
//printf("[Client] list success\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_READ_ERROR:
|
||||
case MOUSEFS_RESULT_READ_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_READ);
|
||||
//printf("[Client] read error\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_READ_SUCCESS:
|
||||
case MOUSEFS_RESULT_READ_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_READ);
|
||||
//printf("[Client] read success\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_WRITE_ERROR:
|
||||
case MOUSEFS_RESULT_WRITE_ERROR:
|
||||
assert(pending.type == PENDING_OPERATION_WRITE);
|
||||
//printf("[Client] write error\n");
|
||||
break;
|
||||
|
||||
case TINYDFS_RESULT_WRITE_SUCCESS:
|
||||
case MOUSEFS_RESULT_WRITE_SUCCESS:
|
||||
assert(pending.type == PENDING_OPERATION_WRITE);
|
||||
//printf("[Client] write success\n");
|
||||
break;
|
||||
}
|
||||
free(pending.ptr);
|
||||
tinydfs_result_free(&result);
|
||||
mousefs_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 = tinydfs_submit_create(
|
||||
client->tdfs,
|
||||
ret = mousefs_submit_create(
|
||||
client->mfs,
|
||||
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 = tinydfs_submit_delete(
|
||||
client->tdfs,
|
||||
ret = mousefs_submit_delete(
|
||||
client->mfs,
|
||||
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 = tinydfs_submit_list(
|
||||
client->tdfs,
|
||||
ret = mousefs_submit_list(
|
||||
client->mfs,
|
||||
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 = tinydfs_submit_read(client->tdfs,
|
||||
ret = mousefs_submit_read(client->mfs,
|
||||
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 = tinydfs_submit_write(
|
||||
client->tdfs,
|
||||
ret = mousefs_submit_write(
|
||||
client->mfs,
|
||||
entry.path,
|
||||
-1,
|
||||
off,
|
||||
@@ -250,12 +250,12 @@ int simulation_client_step(SimulationClient *client, void **contexts,
|
||||
*timeout = 10;
|
||||
else
|
||||
*timeout = -1;
|
||||
return tinydfs_process_events(client->tdfs, contexts, polled, 0);
|
||||
return mousefs_process_events(client->mfs, contexts, polled, 0);
|
||||
}
|
||||
|
||||
void simulation_client_free(SimulationClient *client)
|
||||
{
|
||||
tinydfs_free(client->tdfs);
|
||||
mousefs_free(client->mfs);
|
||||
}
|
||||
|
||||
#endif // BUILD_TEST
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "TinyDFS.h"
|
||||
#include "MouseFS.h"
|
||||
|
||||
#define MAX_PENDING_OPERATION 8
|
||||
|
||||
@@ -29,7 +29,7 @@ typedef struct {
|
||||
} PendingOperation;
|
||||
|
||||
typedef struct {
|
||||
TinyDFS *tdfs;
|
||||
MouseFS *mfs;
|
||||
int num_pending;
|
||||
PendingOperation pending[MAX_PENDING_OPERATION];
|
||||
} SimulationClient;
|
||||
|
||||
Reference in New Issue
Block a user