mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(fatfs): Fixed uninitialized FATFS pointer for already mounted path
Co-authored-by: Cursor <cursoragent@cursor.com> # Conflicts: # components/fatfs/host_test/main/test_fatfs_vfs.cpp # components/fatfs/vfs/vfs_fat_bdl.c
This commit is contained in:
@@ -43,7 +43,9 @@ typedef struct {
|
|||||||
* @param[out] out_fs pointer to FATFS structure which can be used for FATFS f_mount call is returned via this argument.
|
* @param[out] out_fs pointer to FATFS structure which can be used for FATFS f_mount call is returned via this argument.
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK on success
|
||||||
* - ESP_ERR_INVALID_STATE if esp_vfs_fat_register was already called
|
* - ESP_ERR_INVALID_STATE if a filesystem is already registered at this base path.
|
||||||
|
* If @p out_fs is not NULL, @p *out_fs is set to the existing FATFS object so callers
|
||||||
|
* can run f_mount (e.g. remount the same path).
|
||||||
* - ESP_ERR_NO_MEM if not enough memory or too many VFSes already registered
|
* - ESP_ERR_NO_MEM if not enough memory or too many VFSes already registered
|
||||||
*/
|
*/
|
||||||
esp_err_t esp_vfs_fat_register_cfg(const esp_vfs_fat_conf_t* conf, FATFS** out_fs);
|
esp_err_t esp_vfs_fat_register_cfg(const esp_vfs_fat_conf_t* conf, FATFS** out_fs);
|
||||||
|
|||||||
@@ -186,6 +186,9 @@ esp_err_t esp_vfs_fat_register_cfg(const esp_vfs_fat_conf_t* conf, FATFS** out_f
|
|||||||
{
|
{
|
||||||
size_t ctx = find_context_index_by_path(conf->base_path);
|
size_t ctx = find_context_index_by_path(conf->base_path);
|
||||||
if (ctx < FF_VOLUMES) {
|
if (ctx < FF_VOLUMES) {
|
||||||
|
if (out_fs) {
|
||||||
|
*out_fs = &s_fat_ctxs[ctx]->fs;
|
||||||
|
}
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +231,9 @@ esp_err_t esp_vfs_fat_register_cfg(const esp_vfs_fat_conf_t* conf, FATFS** out_f
|
|||||||
//compatibility
|
//compatibility
|
||||||
s_fat_ctx = fat_ctx;
|
s_fat_ctx = fat_ctx;
|
||||||
|
|
||||||
*out_fs = &fat_ctx->fs;
|
if (out_fs) {
|
||||||
|
*out_fs = &fat_ctx->fs;
|
||||||
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ esp_err_t esp_vfs_fat_spiflash_mount_rw_wl(const char* base_path,
|
|||||||
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
||||||
ESP_GOTO_ON_ERROR(ff_diskio_register_wl_partition(pdrv, *wl_handle), fail, TAG, "ff_diskio_register_wl_partition failed pdrv=%i, error - 0x(%x)", pdrv, ret);
|
ESP_GOTO_ON_ERROR(ff_diskio_register_wl_partition(pdrv, *wl_handle), fail, TAG, "ff_diskio_register_wl_partition failed pdrv=%i, error - 0x(%x)", pdrv, ret);
|
||||||
|
|
||||||
FATFS *fs;
|
FATFS *fs = NULL;
|
||||||
esp_vfs_fat_conf_t conf = {
|
esp_vfs_fat_conf_t conf = {
|
||||||
.base_path = base_path,
|
.base_path = base_path,
|
||||||
.fat_drive = drv,
|
.fat_drive = drv,
|
||||||
@@ -366,7 +366,7 @@ esp_err_t esp_vfs_fat_spiflash_mount_ro(const char* base_path,
|
|||||||
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
||||||
ESP_GOTO_ON_ERROR(ff_diskio_register_raw_partition(pdrv, data_partition), fail, TAG, "ff_diskio_register_raw_partition failed pdrv=%i, error - 0x(%x)", pdrv, ret);
|
ESP_GOTO_ON_ERROR(ff_diskio_register_raw_partition(pdrv, data_partition), fail, TAG, "ff_diskio_register_raw_partition failed pdrv=%i, error - 0x(%x)", pdrv, ret);
|
||||||
|
|
||||||
FATFS *fs;
|
FATFS *fs = NULL;
|
||||||
esp_vfs_fat_conf_t conf = {
|
esp_vfs_fat_conf_t conf = {
|
||||||
.base_path = base_path,
|
.base_path = base_path,
|
||||||
.fat_drive = drv,
|
.fat_drive = drv,
|
||||||
|
|||||||
Reference in New Issue
Block a user