Add library build, local cluster script, and example client

Introduce a Makefile that builds libtoastyfs.a and libtoastyfs.so from the
client-side sources (client, tcp, byte_queue, message, basic) so external
programs can link against the ToastyFS client API in include/toastyfs.h.

Add cluster.sh, a convenience script that manages a local 3-node cluster
by spawning toastyfs server processes on ports 8081-8083.  Sub-commands:
up, down, status, logs, and "run <source.c>" which builds the library,
compiles the source against it, starts the cluster, runs the binary, and
tears everything down.

Add examples/example.c demonstrating synchronous PUT, GET, DELETE, and a
NOT_FOUND verification.

Fix a stack overflow in the MAIN_SERVER entry point: ServerState is ~40 MB
(MetaStore holds 4096 ObjectMeta entries) and was declared on the stack.
Heap-allocate it instead.

https://claude.ai/code/session_019DVhmc25jfzcHnmdNxzib2
This commit is contained in:
Claude
2026-02-21 14:51:14 +00:00
parent fe7d79098e
commit 96bd81bae6
5 changed files with 395 additions and 5 deletions
+12 -4
View File
@@ -255,7 +255,14 @@ int main(int argc, char **argv)
int main(int argc, char **argv)
{
int ret;
ServerState state;
// ServerState is ~40 MB (MetaStore holds 4096 ObjectMeta entries),
// which exceeds the default stack size. Heap-allocate it.
ServerState *state = malloc(sizeof(ServerState));
if (state == NULL) {
fprintf(stderr, "Failed to allocate ServerState\n");
return -1;
}
void* poll_ctxs[POLL_CAPACITY];
struct pollfd poll_array[POLL_CAPACITY];
@@ -263,7 +270,7 @@ int main(int argc, char **argv)
int poll_timeout;
ret = server_init(
&state,
state,
argc,
argv,
poll_ctxs,
@@ -284,7 +291,7 @@ int main(int argc, char **argv)
#endif
ret = server_tick(
&state,
state,
poll_ctxs,
poll_array,
POLL_CAPACITY,
@@ -295,7 +302,8 @@ int main(int argc, char **argv)
return -1;
}
server_free(&state);
server_free(state);
free(state);
return 0;
}