Volume-centric VFS implementation
All checks were successful
Build documentation / build-and-deploy (push) Successful in 2m41s

This commit is contained in:
2026-02-25 08:53:54 +01:00
parent 62a6543dab
commit 704db2dfa4
26 changed files with 441 additions and 406 deletions

27
ce/ce.c
View File

@@ -2,6 +2,7 @@
#include <liballoc.h>
#include <list.h>
#include <minmax.h>
#include <path.h>
#include <printf.h>
#include <process.h>
#include <stdbool.h>
@@ -68,36 +69,42 @@ static void cmd_cat (struct list_node_link* tokens) {
}
struct desc desc;
char volume[VOLUME_MAX];
const char* path;
int ret;
struct list_node_link *token_link, *token_tmp_link;
list_foreach (tokens, token_link, token_tmp_link) {
struct token* token = list_entry (token_link, struct token, tokens_link);
int handle = open (token->buffer);
if (handle < 0) {
printf ("ERROR opening %s: %s\n", token->buffer, str_status[-handle]);
if (!path_parse (token->buffer, volume, &path)) {
printf ("ERROR bad path '%s'\n", token->buffer);
continue;
}
describe (handle, &desc);
if ((ret = volume_open (volume)) < 0) {
printf ("ERROR could not open volume '%s': %s\n", volume, str_status[-ret]);
continue;
}
describe (path, &desc);
if (desc.type != FS_FILE)
goto close1;
goto close;
char* buffer = malloc (desc.size + 1);
if (buffer == NULL)
goto close1;
goto close;
memset (buffer, 0, desc.size + 1);
read (handle, 0, (uint8_t*)buffer, desc.size);
read (path, 0, (uint8_t*)buffer, desc.size);
printf ("%s\n", buffer);
close1:
close:
if (buffer != NULL)
free (buffer);
close (handle);
volume_close ();
}
}