mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
spiffs: Add esp_spiffs_check() function
esp_spiffs_check() exposes SPIFFS_check() functionality to the user
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -48,6 +48,7 @@ typedef struct {
|
||||
char path[SPIFFS_OBJ_NAME_LEN]; /*!< Requested directory name */
|
||||
} vfs_spiffs_dir_t;
|
||||
|
||||
static int spiffs_res_to_errno(s32_t fr);
|
||||
static int vfs_spiffs_open(void* ctx, const char * path, int flags, int mode);
|
||||
static ssize_t vfs_spiffs_write(void* ctx, int fd, const void * data, size_t size);
|
||||
static ssize_t vfs_spiffs_read(void* ctx, int fd, void * dst, size_t size);
|
||||
@@ -305,6 +306,22 @@ esp_err_t esp_spiffs_info(const char* partition_label, size_t *total_bytes, size
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_spiffs_check(const char* partition_label)
|
||||
{
|
||||
int index;
|
||||
if (esp_spiffs_by_label(partition_label, &index) != ESP_OK) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (SPIFFS_check(_efs[index]->fs) != SPIFFS_OK) {
|
||||
int spiffs_res = SPIFFS_errno(_efs[index]->fs);
|
||||
ESP_LOGE(TAG, "SPIFFS_check failed (%d)", spiffs_res);
|
||||
errno = spiffs_res_to_errno(SPIFFS_errno(_efs[index]->fs));
|
||||
SPIFFS_clearerr(_efs[index]->fs);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_spiffs_format(const char* partition_label)
|
||||
{
|
||||
bool partition_was_mounted = false;
|
||||
|
Reference in New Issue
Block a user