vfs, fatfs: fix support for two FATFS instances (SD and flash)

- fix null pointer dereference in VFS when VFS implementations are added
  and removed in different order

- vfs_fat_sdmmc, vfs_fat_spiflash: pass correct drive to mkfs
  (previously it would always do mkfs in the first drive)

- add test case
This commit is contained in:
Ivan Grokhotkov
2017-05-04 19:57:11 +08:00
parent 5ac28e843d
commit 53d5c5f668
4 changed files with 58 additions and 8 deletions

View File

@@ -125,6 +125,9 @@ static const vfs_entry_t* get_vfs_for_path(const char* path)
size_t len = strlen(path);
for (size_t i = 0; i < s_vfs_count; ++i) {
const vfs_entry_t* vfs = s_vfs[i];
if (!vfs) {
continue;
}
if (len < vfs->path_prefix_len + 1) { // +1 is for the trailing slash after base path
continue;
}