Accept paths without disk when single fs registered
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2e972af5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2e972af5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2e972af5 Branch: refs/heads/develop Commit: 2e972af5420bd304dc1c7863e9d510575896ddb1 Parents: e5d09d2 Author: Fabio Utzig <[email protected]> Authored: Thu Jan 5 20:34:45 2017 -0200 Committer: Fabio Utzig <[email protected]> Committed: Thu Jan 12 10:51:46 2017 -0200 ---------------------------------------------------------------------- fs/fs/src/fs_file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2e972af5/fs/fs/src/fs_file.c ---------------------------------------------------------------------- diff --git a/fs/fs/src/fs_file.c b/fs/fs/src/fs_file.c index 35c7fe7..c706534 100644 --- a/fs/fs/src/fs_file.c +++ b/fs/fs/src/fs_file.c @@ -22,7 +22,6 @@ #include <disk/disk.h> #include <string.h> #include <stdlib.h> -#include <stdio.h> #include "fs_priv.h" @@ -181,10 +180,19 @@ fops_from_filename(const char *filename) { char *disk; char *fs_name = NULL; + struct fs_ops *unique; disk = disk_from_path(filename); if (disk) { fs_name = disk_fs_for(disk); + } else { + /** + * special case: if only one fs was ever registered, + * return that fs' ops. + */ + if ((unique = fs_ops_try_unique()) != NULL) { + return unique; + } } return safe_fs_ops_for(fs_name); }
