4 Commits
Author SHA1 Message Date
cozis d38f3c24e8 Add proxy options --addr, --max-ops, --client-id 2026-03-28 16:34:28 +01:00
cozis 544a07c63b Fix ubsan warning 2026-03-28 16:12:31 +01:00
cozis 8f4d51d28c Add build.zig 2026-03-28 16:06:14 +01:00
cozis 4db0a934c5 Add cool cluster pic 2026-03-27 18:10:41 +01:00
5 changed files with 123 additions and 6 deletions
+4
View File
@@ -9,6 +9,10 @@ ToastyFS is a simple, fault-tolerant, highly available object storage featuring:
I initially started this project to learn about distributed systems. I asked myself what it would take to build my own Dropbox. A rabbit-hole later and here is my distributed storage system! I initially started this project to learn about distributed systems. I asked myself what it would take to build my own Dropbox. A rabbit-hole later and here is my distributed storage system!
Here is a cool pic of the hardware I'm building to run ToastyFS :D
![photo of an 8 Raspberry PI cluster mouted in a small rack connected via a switch](pic.jpg)
## Table of Contents ## Table of Contents
* [ToastyFS](#toastyfs) * [ToastyFS](#toastyfs)
+85
View File
@@ -0,0 +1,85 @@
const std = @import("std");
const include_paths: []const []const u8 = &.{
".",
"src",
"include",
"quakey/include",
};
const files: []const []const u8 = &.{
"src/chunk_store.c",
"src/client.c",
"src/client_table.c",
"src/http_proxy.c",
"src/invariant_checker.c",
"src/log.c",
"src/main.c",
"src/metadata.c",
"src/random_client.c",
"src/server.c",
"lib/basic.c",
"lib/byte_queue.c",
"lib/file_system.c",
"lib/http_parse.c",
"lib/http_server.c",
"lib/message.c",
"lib/tcp.c",
"lib/tls_openssl.c",
"lib/tls_schannel.c",
"quakey/src/mockfs.c",
"quakey/src/quakey.c",
};
fn buildTarget(b: *std.Build, name: []const u8, macros: []const []const u8, flags: []const []const u8) void {
const exe = b.addExecutable(.{
.name = name,
.root_module = b.createModule(.{
.target = b.graph.host,
}),
});
for (macros) |m| {
exe.root_module.addCMacro(m, "");
}
for (include_paths) |p| {
exe.root_module.addIncludePath(b.path(p));
}
exe.root_module.addCSourceFiles(.{ .files = files, .flags = flags });
exe.root_module.link_libc = true;
b.installArtifact(exe);
}
pub fn build(b: *std.Build) !void {
// Server
buildTarget(b,
"toasty",
&.{ "MAIN_SERVER" },
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
);
// Client
buildTarget(b,
"toasty_random_client",
&.{ "MAIN_CLIENT" },
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
);
// Proxy
buildTarget(b,
"toasty_proxy",
&.{ "MAIN_HTTP_PROXY" },
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
);
// Simulation
buildTarget(b,
"toasty_simulation",
&.{ "MAIN_SIMULATION", "FAULT_INJECTION" },
&.{ "-Wall", "-Wextra", "-ggdb", "-O0" },
);
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

+33 -5
View File
@@ -19,6 +19,10 @@ int http_proxy_init(void *state, int argc, char **argv,
char *addrs[NODE_LIMIT]; char *addrs[NODE_LIMIT];
int num_addrs = 0; int num_addrs = 0;
int max_opers = 128;
string http_addr = S("127.0.0.1:3000");
uint64_t client_id = 999;
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
if (!strcmp(argv[i], "--server")) { if (!strcmp(argv[i], "--server")) {
i++; i++;
@@ -32,16 +36,40 @@ int http_proxy_init(void *state, int argc, char **argv,
} }
addrs[num_addrs] = argv[i]; addrs[num_addrs] = argv[i];
num_addrs++; num_addrs++;
} else if (!strcmp(argv[i], "--addr")) {
i++;
if (i == argc) {
fprintf(stderr, "Option --addr missing value\n");
return -1;
}
http_addr = (string) { argv[i], strlen(argv[i]) };
} else if (!strcmp(argv[i], "--max-ops")) {
i++;
if (i == argc) {
fprintf(stderr, "Option --max-ops missing value\n");
return -1;
}
max_opers = atoi(argv[i]); // TODO: don't use atoi
if (max_opers == 0) {
fprintf(stderr, "Invalid value for option --max-ops\n");
return -1;
}
} else if (!strcmp(argv[i], "--client-id")) {
i++;
if (i == argc) {
fprintf(stderr, "Invalid value for option --client-id\n");
return -1;
}
client_id = atoi(argv[i]);
if (client_id == 0) {
fprintf(stderr, "Invalid value for option --client-id\n");
return -1;
}
} else { } else {
// Ignore unknown options // Ignore unknown options
} }
} }
// TODO: Make these configurable
int max_opers = 128;
string http_addr = S("127.0.0.1:3000");
uint64_t client_id = 999;
proxy->max_opers = max_opers; proxy->max_opers = max_opers;
proxy->opers = malloc(max_opers * sizeof(ProxyOper)); proxy->opers = malloc(max_opers * sizeof(ProxyOper));
if (proxy->opers == NULL) if (proxy->opers == NULL)
+1 -1
View File
@@ -75,7 +75,7 @@ static void node_log_impl(Server *state, const char *event, const char *detail)
static int count_set(uint32_t word) static int count_set(uint32_t word)
{ {
int n = 0; int n = 0;
for (int i = 0; i < (int) sizeof(word) * 8; i++) for (int i = 0; i < (int) sizeof(word) * 8 - 1; i++)
if (word & (1 << i)) if (word & (1 << i))
n++; n++;
return n; return n;