examples/filesystem: Cleanup filesystem/mtd check
This commit is contained in:
parent
b1ff897256
commit
9f77c3c997
@ -130,6 +130,18 @@ static vfs_mount_t flash_mount = {
|
|||||||
};
|
};
|
||||||
#endif /* MTD_0 */
|
#endif /* MTD_0 */
|
||||||
|
|
||||||
|
/* Add simple macro to check if an MTD device together with a filesystem is
|
||||||
|
* compiled in */
|
||||||
|
#if defined(MTD_0) && \
|
||||||
|
(defined(MODULE_SPIFFS) || \
|
||||||
|
defined(MODULE_LITTLEFS) || \
|
||||||
|
defined(MODULE_LITTLEFS2) || \
|
||||||
|
defined(MODULE_FATFS_VFS))
|
||||||
|
#define FLASH_AND_FILESYSTEM_PRESENT 1
|
||||||
|
#else
|
||||||
|
#define FLASH_AND_FILESYSTEM_PRESENT 0
|
||||||
|
#endif
|
||||||
|
|
||||||
/* constfs example */
|
/* constfs example */
|
||||||
#include "fs/constfs.h"
|
#include "fs/constfs.h"
|
||||||
|
|
||||||
@ -169,7 +181,7 @@ static int _mount(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
|
#if FLASH_AND_FILESYSTEM_PRESENT
|
||||||
int res = vfs_mount(&flash_mount);
|
int res = vfs_mount(&flash_mount);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
printf("Error while mounting %s...try format\n", FLASH_MOUNT_POINT);
|
printf("Error while mounting %s...try format\n", FLASH_MOUNT_POINT);
|
||||||
@ -188,7 +200,7 @@ static int _format(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
|
#if FLASH_AND_FILESYSTEM_PRESENT
|
||||||
int res = vfs_format(&flash_mount);
|
int res = vfs_format(&flash_mount);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
printf("Error while formatting %s\n", FLASH_MOUNT_POINT);
|
printf("Error while formatting %s\n", FLASH_MOUNT_POINT);
|
||||||
@ -207,7 +219,7 @@ static int _umount(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
(void)argc;
|
(void)argc;
|
||||||
(void)argv;
|
(void)argv;
|
||||||
#if defined(MTD_0) && (defined(MODULE_SPIFFS) || defined(MODULE_LITTLEFS) || defined(MODULE_LITTLEFS2) || defined(MODULE_FATFS_VFS))
|
#if FLASH_AND_FILESYSTEM_PRESENT
|
||||||
int res = vfs_umount(&flash_mount);
|
int res = vfs_umount(&flash_mount);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
printf("Error while unmounting %s\n", FLASH_MOUNT_POINT);
|
printf("Error while unmounting %s\n", FLASH_MOUNT_POINT);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user