CE add rm command, implement remove () syscall
All checks were successful
Build documentation / build-and-deploy (push) Successful in 1m51s

This commit is contained in:
2026-03-05 01:17:13 +01:00
parent 35d5bed433
commit a5f5dbf21f
12 changed files with 106 additions and 7 deletions

View File

@@ -73,6 +73,30 @@ static void mkdir (struct context* context, char** dir_paths, size_t dirs_count)
}
}
static void rm (struct context* context, char** paths, size_t count) {
char volume[VOLUME_MAX];
const char* path;
int ret;
for (size_t i = 0; i < count; i++) {
const char* path1 = paths[i];
if (!path_parse (path1, volume, &path)) {
cprintf (context, "ERROR bad path '%s'\n", path1);
continue;
}
if ((ret = volume_open (volume)) < 0) {
cprintf (context, "ERROR could not open volume '%s': %s\n", volume, str_status[-ret]);
continue;
}
remove (path);
volume_close ();
}
}
static void cat (struct context* context, char** file_paths, size_t files_count) {
char volume[VOLUME_MAX];
const char* path;
@@ -172,12 +196,13 @@ static void quit1 (struct context* context) {
static void help (struct context* context) {
cprintf (context, "Available commands:\n");
cprintf (context, "echo <word1> <word2> <word3> ...\n");
cprintf (context, "help\n");
cprintf (context, "cat <file path>\n");
cprintf (context, "ls <directory path>\n");
cprintf (context, "mkfile <file path>\n");
cprintf (context, "mkdir <directory path>\n");
cprintf (context, "echo <word1> <word2> <word3> ...\n");
cprintf (context, "cat <file path>\n");
cprintf (context, "ls <directory path>\n");
cprintf (context, "mkfile <file path>\n");
cprintf (context, "mkdir <directory path>\n");
cprintf (context, "rm <path>\n");
cprintf (context, "quit\n");
}
@@ -212,8 +237,9 @@ static void execute_cmd (struct ast_cmd* cmd, struct context* context) {
mkfile (context, cmd->args, cmd->arg_count);
} else if (strcmp (cmd->name, "mkdir") == 0) {
mkdir (context, cmd->args, cmd->arg_count);
} else if (strcmp (cmd->name, "rm") == 0) {
rm (context, cmd->args, cmd->arg_count);
} else {
/* cprintf (context, "ERROR unknown command '%s'\n", cmd->name); */
char volume[VOLUME_MAX];
const char* path;