Skip to content

Commit 6231a9e

Browse files
xudongzhengkartben
authored andcommitted
fs: shell: Add configuration option for mount subcommand
The mount subcommand requires the heap to be present. Excluding it reduces flash and RAM usage. Signed-off-by: Xudong Zheng <[email protected]>
1 parent fdf0ec2 commit 6231a9e

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

subsys/fs/Kconfig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,21 @@ config FILE_SYSTEM_INIT_PRIORITY
6565
config FILE_SYSTEM_SHELL
6666
bool "File system shell"
6767
depends on SHELL
68-
depends on HEAP_MEM_POOL_SIZE > 0
6968
help
7069
This shell provides basic browsing of the contents of the
7170
file system.
7271

7372
if FILE_SYSTEM_SHELL
7473

74+
config FILE_SYSTEM_SHELL_MOUNT_COMMAND
75+
bool "File system shell mount command"
76+
depends on FAT_FILESYSTEM_ELM || FILE_SYSTEM_LITTLEFS
77+
depends on HEAP_MEM_POOL_SIZE > 0
78+
default y
79+
help
80+
Enable file system shell command for mounting file systems. This
81+
requires the heap to be present.
82+
7583
config FILE_SYSTEM_SHELL_TEST_COMMANDS
7684
bool "File system shell read/write/erase test commands"
7785
select CBPRINTF_FP_SUPPORT

subsys/fs/shell.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define STORAGE_PARTITION storage_partition
2121
#define STORAGE_PARTITION_ID FIXED_PARTITION_ID(STORAGE_PARTITION)
2222

23+
#ifdef CONFIG_FILE_SYSTEM_SHELL_MOUNT_COMMAND
2324
/* FAT */
2425
#ifdef CONFIG_FAT_FILESYSTEM_ELM
2526
#include <ff.h>
@@ -72,6 +73,7 @@ static struct fs_mount_t littlefs_mnt = {
7273
};
7374
#endif
7475
#endif
76+
#endif
7577

7678
#define BUF_CNT 64
7779

@@ -745,8 +747,8 @@ static int cmd_erase_write_test(const struct shell *sh, size_t argc, char **argv
745747
}
746748
#endif
747749

748-
#if defined(CONFIG_FAT_FILESYSTEM_ELM) \
749-
|| defined(CONFIG_FILE_SYSTEM_LITTLEFS)
750+
#ifdef CONFIG_FILE_SYSTEM_SHELL_MOUNT_COMMAND
751+
750752
static char *mntpt_prepare(char *mntpt)
751753
{
752754
char *cpy_mntpt;
@@ -757,7 +759,6 @@ static char *mntpt_prepare(char *mntpt)
757759
}
758760
return cpy_mntpt;
759761
}
760-
#endif
761762

762763
#if defined(CONFIG_FAT_FILESYSTEM_ELM)
763764
static int cmd_mount_fat(const struct shell *sh, size_t argc, char **argv)
@@ -790,7 +791,6 @@ static int cmd_mount_fat(const struct shell *sh, size_t argc, char **argv)
790791
#endif
791792

792793
#if defined(CONFIG_FILE_SYSTEM_LITTLEFS)
793-
794794
static int cmd_mount_littlefs(const struct shell *sh, size_t argc, char **argv)
795795
{
796796
if (littlefs_mnt.mnt_point != NULL) {
@@ -819,8 +819,6 @@ static int cmd_mount_littlefs(const struct shell *sh, size_t argc, char **argv)
819819
}
820820
#endif
821821

822-
#if defined(CONFIG_FAT_FILESYSTEM_ELM) \
823-
|| defined(CONFIG_FILE_SYSTEM_LITTLEFS)
824822
SHELL_STATIC_SUBCMD_SET_CREATE(sub_fs_mount,
825823
#if defined(CONFIG_FAT_FILESYSTEM_ELM)
826824
SHELL_CMD_ARG(fat, NULL,
@@ -842,8 +840,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(sub_fs,
842840
SHELL_CMD(cd, NULL, "Change working directory", cmd_cd),
843841
SHELL_CMD(ls, NULL, "List files in current directory", cmd_ls),
844842
SHELL_CMD_ARG(mkdir, NULL, "Create directory", cmd_mkdir, 2, 0),
845-
#if defined(CONFIG_FAT_FILESYSTEM_ELM) \
846-
|| defined(CONFIG_FILE_SYSTEM_LITTLEFS)
843+
#ifdef CONFIG_FILE_SYSTEM_SHELL_MOUNT_COMMAND
847844
SHELL_CMD(mount, &sub_fs_mount,
848845
"<Mount fs, syntax:- fs mount <fs type> <mount-point>", NULL),
849846
#endif

0 commit comments

Comments
 (0)