shell: mufs: expose individual commands

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent bba75900c0
commit 501b80e87c
  1. 14
      include/shell/mufs.h
  2. 50
      source/shell/mufs.c

@ -0,0 +1,14 @@
#pragma once
void shell_mount(struct console *con, const char **argv, size_t argc);
void shell_unmount(struct console *con, const char **argv, size_t argc);
void shell_format(struct console *con, const char **argv, size_t argc);
void shell_mkdir(struct console *con, const char **argv, size_t argc);
void shell_rmdir(struct console *con, const char **argv, size_t argc);
void shell_stat(struct console *con, const char **argv, size_t argc);
void shell_cat(struct console *con, const char **argv, size_t argc);
void shell_write(struct console *con, const char **argv, size_t argc);
void shell_append(struct console *con, const char **argv, size_t argc);
void shell_mv(struct console *con, const char **argv, size_t argc);
void shell_rm(struct console *con, const char **argv, size_t argc);
void shell_ls(struct console *con, const char **argv, size_t argc);

@ -15,10 +15,12 @@
#include <fs/mufs.h>
#include <shell/mufs.h>
extern struct flash_dev *flash;
struct mufs *mufs = NULL;
static void do_mufs_mount(struct console *con, const char **argv, size_t argc)
void shell_mount(struct console *con, const char **argv, size_t argc)
{
(void)argc;
(void)argv;
@ -41,7 +43,7 @@ static void do_mufs_mount(struct console *con, const char **argv, size_t argc)
flash = NULL;
}
static void do_mufs_unmount(struct console *con, const char **argv, size_t argc)
void shell_unmount(struct console *con, const char **argv, size_t argc)
{
(void)argc;
(void)argv;
@ -61,7 +63,7 @@ static void do_mufs_unmount(struct console *con, const char **argv, size_t argc)
mufs = NULL;
}
static void do_mufs_format(struct console *con, const char **argv, size_t argc)
void shell_format(struct console *con, const char **argv, size_t argc)
{
(void)argc;
(void)argv;
@ -77,7 +79,7 @@ static void do_mufs_format(struct console *con, const char **argv, size_t argc)
}
}
static void do_mufs_mkdir(struct console *con, const char **argv, size_t argc)
void shell_mkdir(struct console *con, const char **argv, size_t argc)
{
if (argc < 1) {
fprintf(con->fp, "usage: mufs mkdir <path>\n");
@ -95,7 +97,7 @@ static void do_mufs_mkdir(struct console *con, const char **argv, size_t argc)
}
}
static void do_mufs_rmdir(struct console *con, const char **argv, size_t argc)
void shell_rmdir(struct console *con, const char **argv, size_t argc)
{
if (argc < 1) {
fprintf(con->fp, "usage: mufs rmdir <path>\n");
@ -113,7 +115,7 @@ static void do_mufs_rmdir(struct console *con, const char **argv, size_t argc)
}
}
static void do_mufs_stat(struct console *con, const char **argv, size_t argc)
void shell_stat(struct console *con, const char **argv, size_t argc)
{
struct mufs_stat stat;
@ -141,7 +143,7 @@ static void do_mufs_stat(struct console *con, const char **argv, size_t argc)
printf(" file size: %" PRIu32 " bytes\n", stat.file_size);
}
static void do_mufs_cat(struct console *con, const char **argv, size_t argc)
void shell_cat(struct console *con, const char **argv, size_t argc)
{
char data[256];
struct mufs_file *file;
@ -168,7 +170,7 @@ static void do_mufs_cat(struct console *con, const char **argv, size_t argc)
mufs_close(file);
}
static void do_mufs_write(struct console *con, const char **argv, size_t argc)
void shell_write(struct console *con, const char **argv, size_t argc)
{
char data[256];
struct mufs_file *file;
@ -199,7 +201,7 @@ static void do_mufs_write(struct console *con, const char **argv, size_t argc)
mufs_close(file);
}
static void do_mufs_append(struct console *con, const char **argv, size_t argc)
void shell_append(struct console *con, const char **argv, size_t argc)
{
struct mufs_file *file;
char data[256];
@ -230,7 +232,7 @@ static void do_mufs_append(struct console *con, const char **argv, size_t argc)
mufs_close(file);
}
static void do_mufs_mv(struct console *con, const char **argv, size_t argc)
void shell_mv(struct console *con, const char **argv, size_t argc)
{
if (argc < 2) {
fprintf(con->fp, "usage: mufs mv <old> <new>\n");
@ -248,7 +250,7 @@ static void do_mufs_mv(struct console *con, const char **argv, size_t argc)
}
}
static void do_mufs_rm(struct console *con, const char **argv, size_t argc)
void shell_rm(struct console *con, const char **argv, size_t argc)
{
if (argc < 1) {
fprintf(con->fp, "usage: mufs rm <path>\n");
@ -266,7 +268,7 @@ static void do_mufs_rm(struct console *con, const char **argv, size_t argc)
}
}
static void do_mufs_ls(struct console *con, const char **argv, size_t argc)
void shell_ls(struct console *con, const char **argv, size_t argc)
{
struct mufs_dirent ent;
struct mufs_dir *dir;
@ -294,18 +296,18 @@ static void do_mufs_ls(struct console *con, const char **argv, size_t argc)
}
static struct cmd mufs_cmds[] = {
{ "mount", NULL, do_mufs_mount },
{ "umount", NULL, do_mufs_unmount },
{ "format", NULL, do_mufs_format },
{ "mkdir", NULL, do_mufs_mkdir },
{ "rmdir", NULL, do_mufs_rmdir },
{ "ls", NULL, do_mufs_ls },
{ "stat", NULL, do_mufs_stat },
{ "cat", NULL, do_mufs_cat },
{ "write", NULL, do_mufs_write },
{ "append", NULL, do_mufs_append },
{ "mv", NULL, do_mufs_mv, },
{ "rm", NULL, do_mufs_rm, },
{ "mount", NULL, shell_mount },
{ "umount", NULL, shell_unmount },
{ "format", NULL, shell_format },
{ "mkdir", NULL, shell_mkdir },
{ "rmdir", NULL, shell_rmdir },
{ "ls", NULL, shell_ls },
{ "stat", NULL, shell_stat },
{ "cat", NULL, shell_cat },
{ "write", NULL, shell_write },
{ "append", NULL, shell_append },
{ "mv", NULL, shell_mv, },
{ "rm", NULL, shell_rm, },
{ NULL, NULL, NULL },
};

Loading…
Cancel
Save