Add create_file syscall, CE mkfile command, FatFS formatting fixes
All checks were successful
Build documentation / build-and-deploy (push) Successful in 4m16s

This commit is contained in:
2026-03-01 01:52:09 +01:00
parent eb55a6de21
commit abd85744cc
13 changed files with 133 additions and 18 deletions

31
ce/ce.c
View File

@@ -19,7 +19,7 @@ static struct arena arena;
#define LINE_BUFFER_MAX 1024
#define TOKEN_MAX 64
#define CMD_ARGS_MAX 64
#define PROMPT "ce $ "
#define PROMPT "$ "
#define TOKEN_CLASS_OPAREN 0
#define TOKEN_CLASS_CPAREN 1
@@ -235,7 +235,31 @@ static void parse_tokens (struct list_node_link* tokens) {
static void echo (char** strings, size_t strings_count) {
for (size_t i = 0; i < strings_count; i++)
printf ("%s\n", strings[i]);
printf ("%s ", strings[i]);
}
static void mkfile (char** file_paths, size_t files_count) {
char volume[VOLUME_MAX];
const char* path;
int ret;
for (size_t i = 0; i < files_count; i++) {
const char* file_path = file_paths[i];
if (!path_parse (file_path, volume, &path)) {
printf ("ERROR bad path '%s'\n", file_path);
continue;
}
if ((ret = volume_open (volume)) < 0) {
printf ("ERROR could not open volume '%s': %s\n", volume, str_status[-ret]);
continue;
}
create_file (path);
volume_close ();
}
}
static void cat (char** file_paths, size_t files_count) {
@@ -328,6 +352,7 @@ static void help (void) {
printf ("help\n");
printf ("cat <file path>\n");
printf ("ls <directory path>\n");
printf ("mkfile <file path>\n");
printf ("quit\n");
}
@@ -342,6 +367,8 @@ static void execute_cmd (struct ast_cmd* cmd) {
ls (cmd->args[0]);
} else if (strcmp (cmd->name, "quit") == 0) {
quit1 ();
} else if (strcmp (cmd->name, "mkfile") == 0) {
mkfile (cmd->args, cmd->arg_count);
} else {
printf ("ERROR unknown command '%s'\n", cmd->name);
}