|
|
|
@ -42,7 +42,7 @@ static struct cmd mufs_cmds[] = { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
extern struct flash_dev *flash; |
|
|
|
|
struct mufs *mufs; |
|
|
|
|
struct mufs *mufs = NULL; |
|
|
|
|
|
|
|
|
|
static void do_mufs_mount(const char *s) |
|
|
|
|
{ |
|
|
|
@ -97,6 +97,11 @@ static void do_mufs_format(const char *s) |
|
|
|
|
|
|
|
|
|
static void do_mufs_mkdir(const char *s) |
|
|
|
|
{ |
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mufs_mkdir(mufs, s) < 0) { |
|
|
|
|
fprintf(stderr, "error: unable to create the directory\n"); |
|
|
|
|
return; |
|
|
|
@ -105,6 +110,11 @@ static void do_mufs_mkdir(const char *s) |
|
|
|
|
|
|
|
|
|
static void do_mufs_rmdir(const char *s) |
|
|
|
|
{ |
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mufs_rmdir(mufs, s) < 0) { |
|
|
|
|
fprintf(stderr, "error: unable to remove the directory\n"); |
|
|
|
|
return; |
|
|
|
@ -115,6 +125,11 @@ static void do_mufs_stat(const char *s) |
|
|
|
|
{ |
|
|
|
|
struct mufs_stat stat; |
|
|
|
|
|
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mufs_stat(mufs, s, &stat) < 0) { |
|
|
|
|
fprintf(stderr, "error: unable to stat the file\n"); |
|
|
|
|
return; |
|
|
|
@ -134,6 +149,11 @@ static void do_mufs_cat(const char *s) |
|
|
|
|
char data[256]; |
|
|
|
|
struct mufs_file *file; |
|
|
|
|
|
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(file = mufs_open(mufs, s, MUFS_READ))) { |
|
|
|
|
fprintf(stderr, "error: unable to open the file\n"); |
|
|
|
|
return; |
|
|
|
@ -151,6 +171,11 @@ static void do_mufs_append(const char *s) |
|
|
|
|
struct mufs_file *file; |
|
|
|
|
char *path, *line; |
|
|
|
|
|
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(path = malloc(strlen(s) + 2))) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
@ -180,6 +205,11 @@ static void do_mufs_mv(const char *s) |
|
|
|
|
{ |
|
|
|
|
char *old, *new; |
|
|
|
|
|
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(old = strdup(s))) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
@ -201,6 +231,11 @@ err_free_old: |
|
|
|
|
|
|
|
|
|
static void do_mufs_rm(const char *s) |
|
|
|
|
{ |
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (mufs_unlink(mufs, s) < 0) { |
|
|
|
|
fprintf(stderr, "error: unable to remove the file\n"); |
|
|
|
|
return; |
|
|
|
@ -212,6 +247,11 @@ static void do_mufs_ls(const char *s) |
|
|
|
|
struct mufs_dirent ent; |
|
|
|
|
struct mufs_dir *dir; |
|
|
|
|
|
|
|
|
|
if (!mufs) { |
|
|
|
|
fprintf(stderr, "error: no file system mounted.\n"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!(dir = mufs_opendir(mufs, s))) { |
|
|
|
|
fprintf(stderr, "error: unable to open the directory\n"); |
|
|
|
|
return; |
|
|
|
|