From 3819d93b4e41c80c4849697048d40010ae282c99 Mon Sep 17 00:00:00 2001 From: Gustavo Henrique Nihei Date: Fri, 22 Oct 2021 10:45:13 -0300 Subject: [PATCH] fs/mount: Properly handle missing FS on the supported list Instead of reporting the failure to find a given FS, nx_mount was reporting a failure to find the block driver, even when the actual block driver exists. Signed-off-by: Gustavo Henrique Nihei --- fs/mount/fs_mount.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/mount/fs_mount.c b/fs/mount/fs_mount.c index 39bb8da53b..b0c7d2eb54 100644 --- a/fs/mount/fs_mount.c +++ b/fs/mount/fs_mount.c @@ -266,11 +266,9 @@ int nx_mount(FAR const char *source, FAR const char *target, FAR const void *data) { #if defined(BDFS_SUPPORT) || defined(MDFS_SUPPORT) || defined(NODFS_SUPPORT) -#if defined(BDFS_SUPPORT) || defined(MDFS_SUPPORT) FAR struct inode *drvr_inode = NULL; -#endif FAR struct inode *mountpt_inode; - FAR const struct mountpt_operations *mops; + FAR const struct mountpt_operations *mops = NULL; #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS struct inode_search_s desc; #endif @@ -283,13 +281,14 @@ int nx_mount(FAR const char *source, FAR const char *target, /* Find the specified filesystem. Try the block driver filesystems first */ -#ifdef BDFS_SUPPORT if (source != NULL && find_blockdriver(source, mountflags, &drvr_inode) >= 0) { /* Find the block based file system */ +#ifdef BDFS_SUPPORT mops = mount_findfs(g_bdfsmap, filesystemtype); +#endif /* BDFS_SUPPORT */ if (mops == NULL) { ferr("ERROR: Failed to find block based file system %s\n", @@ -299,14 +298,14 @@ int nx_mount(FAR const char *source, FAR const char *target, goto errout_with_inode; } } - else -#endif /* BDFS_SUPPORT */ -#ifdef MDFS_SUPPORT - if (source != NULL && (ret = find_mtddriver(source, &drvr_inode)) >= 0) + else if (source != NULL && + (ret = find_mtddriver(source, &drvr_inode)) >= 0) { /* Find the MTD based file system */ +#ifdef MDFS_SUPPORT mops = mount_findfs(g_mdfsmap, filesystemtype); +#endif /* MDFS_SUPPORT */ if (mops == NULL) { ferr("ERROR: Failed to find MTD based file system %s\n", @@ -317,7 +316,6 @@ int nx_mount(FAR const char *source, FAR const char *target, } } else -#endif /* MDFS_SUPPORT */ #ifdef NODFS_SUPPORT if ((mops = mount_findfs(g_nonbdfsmap, filesystemtype)) != NULL) {