From 5379df28a84095409ecc1237699724c575c28980 Mon Sep 17 00:00:00 2001 From: Aurel Feer Date: Wed, 1 Jun 2022 23:04:03 +0200 Subject: [PATCH] add filesystem command stubs --- usr/shelly/Hakefile | 2 +- usr/shelly/shelly.c | 6 +++++ usr/shelly/shelly_cmd.c | 51 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/usr/shelly/Hakefile b/usr/shelly/Hakefile index 562fc05..773fa4b 100644 --- a/usr/shelly/Hakefile +++ b/usr/shelly/Hakefile @@ -14,6 +14,6 @@ { target = "shelly", cFiles = [ "shelly.c" ], - addLibraries = [ "lpuart", "gic_dist" ] + addLibraries = [ "lpuart", "gic_dist", "fs" ] } ] diff --git a/usr/shelly/shelly.c b/usr/shelly/shelly.c index fcc6088..cce9f67 100644 --- a/usr/shelly/shelly.c +++ b/usr/shelly/shelly.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "shelly.h" @@ -274,6 +275,11 @@ int main(int argc, char *argv[]) SHELLY_DEBUG("registered as shelly server\n"); + // err = filesystem_init(); + // if (err_is_fail(err)) DEBUG_ERR(err, "Failed to init filesystem"); + + // SHELLY_DEBUG("initialized filesystem\n"); + err = shelly_write_str("Welcome to Shelly(TM)(TM)!\n\r"); if (err_is_fail(err)) USER_PANIC_ERR(err, "while trying to write welcome message"); diff --git a/usr/shelly/shelly_cmd.c b/usr/shelly/shelly_cmd.c index 8ccf5a6..a27c264 100644 --- a/usr/shelly/shelly_cmd.c +++ b/usr/shelly/shelly_cmd.c @@ -24,12 +24,55 @@ static errval_t shelly_cmd_help(char * line) { if (err_is_fail(err)) return err; err = shelly_write_str("- ps\n\r"); if (err_is_fail(err)) return err; + err = shelly_write_str("- ls\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str("- cat\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str(" ...meow\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str("- mkdir\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str("- rmdir\n\r"); + if (err_is_fail(err)) return err; err = shelly_write_str("- help\n\r"); if (err_is_fail(err)) return err; return SYS_ERR_OK; } +static errval_t shelly_cmd_ls(char * line) { + // errval_t err; + + return SYS_ERR_OK; +} + +static errval_t shelly_cmd_cat(char * line) { + errval_t err; + + err = shelly_write_str(" /\\_/\\ ___\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str(" = o_o =_______ \\ \\\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str(" __^ __( \\.__) )\n\r"); + if (err_is_fail(err)) return err; + err = shelly_write_str("(@)<_____>__(_____)____/\n\r"); + if (err_is_fail(err)) return err; + + return SYS_ERR_OK; +} + +static errval_t shelly_cmd_mkdir(char * line) { + // errval_t err; + + return SYS_ERR_OK; +} + +static errval_t shelly_cmd_rmdir(char * line) { + // errval_t err; + + return SYS_ERR_OK; +} + static errval_t shelly_cmd_echo(char * line) { errval_t err; err = shelly_write_str(line); @@ -98,6 +141,14 @@ static errval_t handle_shelly_cmd(char* line, size_t len) { return shelly_cmd_ps(remaining_line); } else if (strcmp(cmd, "help") == 0) { return shelly_cmd_help(remaining_line); + } else if (strcmp(cmd, "ls") == 0) { + return shelly_cmd_ls(remaining_line); + } else if (strcmp(cmd, "cat") == 0) { + return shelly_cmd_cat(remaining_line); + } else if (strcmp(cmd, "mkdir") == 0) { + return shelly_cmd_mkdir(remaining_line); + } else if (strcmp(cmd, "rmdir") == 0) { + return shelly_cmd_rmdir(remaining_line); } else { char buf[256]; snprintf(buf, 256, "unknown command \"%s\"\n\r", cmd);