Skip to content
Permalink
Browse files

subsys/fs/shell: add statvfs command

Shows the file system state.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
  • Loading branch information...
pabigot authored and nashif committed Jul 23, 2019
1 parent 56886b0 commit 8ce4d071c22fa83e4332d225d59d6fa006ddb2a7
Showing with 22 additions and 0 deletions.
  1. +22 −0 subsys/fs/shell.c
@@ -319,6 +319,27 @@ static int cmd_read(const struct shell *shell, size_t argc, char **argv)
return 0;
}

static int cmd_statvfs(const struct shell *shell, size_t argc, char **argv)
{
int err;
char path[MAX_PATH_LEN];
struct fs_statvfs stat;

create_abs_path(argv[1], path, sizeof(path));

err = fs_statvfs(path, &stat);
if (err < 0) {
shell_error(shell, "Failed to statvfs %s (%d)", path, err);
return -ENOEXEC;
}

shell_fprintf(shell, SHELL_NORMAL,
"bsize %lu, frsize %lu, blocks %lu, bfree %lu\n",
stat.f_bsize, stat.f_frsize, stat.f_blocks, stat.f_bfree);

return 0;
}

static int cmd_write(const struct shell *shell, size_t argc, char **argv)
{
char path[MAX_PATH_LEN];
@@ -489,6 +510,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_fs,
SHELL_CMD(pwd, NULL, "Print current working directory", cmd_pwd),
SHELL_CMD_ARG(read, NULL, "Read from file", cmd_read, 2, 255),
SHELL_CMD_ARG(rm, NULL, "Remove file", cmd_rm, 2, 0),
SHELL_CMD_ARG(statvfs, NULL, "Show file system state", cmd_statvfs, 2, 0),
SHELL_CMD_ARG(trunc, NULL, "Truncate file", cmd_trunc, 2, 255),
SHELL_CMD_ARG(write, NULL, "Write file", cmd_write, 3, 255),
SHELL_SUBCMD_SET_END

0 comments on commit 8ce4d07

Please sign in to comment.
You can’t perform that action at this time.