Lines Matching refs:efs
98 static void esp_spiffs_free(esp_spiffs_t ** efs) in esp_spiffs_free() argument
100 esp_spiffs_t * e = *efs; in esp_spiffs_free()
101 if (*efs == NULL) { in esp_spiffs_free()
104 *efs = NULL; in esp_spiffs_free()
182 esp_spiffs_t * efs = malloc(sizeof(esp_spiffs_t)); in esp_spiffs_init() local
183 if (efs == NULL) { in esp_spiffs_init()
187 memset(efs, 0, sizeof(esp_spiffs_t)); in esp_spiffs_init()
189 efs->cfg.hal_erase_f = spiffs_api_erase; in esp_spiffs_init()
190 efs->cfg.hal_read_f = spiffs_api_read; in esp_spiffs_init()
191 efs->cfg.hal_write_f = spiffs_api_write; in esp_spiffs_init()
192 efs->cfg.log_block_size = g_rom_flashchip.sector_size; in esp_spiffs_init()
193 efs->cfg.log_page_size = log_page_size; in esp_spiffs_init()
194 efs->cfg.phys_addr = 0; in esp_spiffs_init()
195 efs->cfg.phys_erase_block = g_rom_flashchip.sector_size; in esp_spiffs_init()
196 efs->cfg.phys_size = partition->size; in esp_spiffs_init()
198 efs->by_label = conf->partition_label != NULL; in esp_spiffs_init()
200 efs->lock = xSemaphoreCreateMutex(); in esp_spiffs_init()
201 if (efs->lock == NULL) { in esp_spiffs_init()
203 esp_spiffs_free(&efs); in esp_spiffs_init()
207 efs->fds_sz = conf->max_files * sizeof(spiffs_fd); in esp_spiffs_init()
208 efs->fds = malloc(efs->fds_sz); in esp_spiffs_init()
209 if (efs->fds == NULL) { in esp_spiffs_init()
211 esp_spiffs_free(&efs); in esp_spiffs_init()
214 memset(efs->fds, 0, efs->fds_sz); in esp_spiffs_init()
217 efs->cache_sz = sizeof(spiffs_cache) + conf->max_files * (sizeof(spiffs_cache_page) in esp_spiffs_init()
218 + efs->cfg.log_page_size); in esp_spiffs_init()
219 efs->cache = malloc(efs->cache_sz); in esp_spiffs_init()
220 if (efs->cache == NULL) { in esp_spiffs_init()
222 esp_spiffs_free(&efs); in esp_spiffs_init()
225 memset(efs->cache, 0, efs->cache_sz); in esp_spiffs_init()
228 const uint32_t work_sz = efs->cfg.log_page_size * 2; in esp_spiffs_init()
229 efs->work = malloc(work_sz); in esp_spiffs_init()
230 if (efs->work == NULL) { in esp_spiffs_init()
232 esp_spiffs_free(&efs); in esp_spiffs_init()
235 memset(efs->work, 0, work_sz); in esp_spiffs_init()
237 efs->fs = malloc(sizeof(spiffs)); in esp_spiffs_init()
238 if (efs->fs == NULL) { in esp_spiffs_init()
240 esp_spiffs_free(&efs); in esp_spiffs_init()
243 memset(efs->fs, 0, sizeof(spiffs)); in esp_spiffs_init()
245 efs->fs->user_data = (void *)efs; in esp_spiffs_init()
246 efs->partition = partition; in esp_spiffs_init()
248 s32_t res = SPIFFS_mount(efs->fs, &efs->cfg, efs->work, efs->fds, efs->fds_sz, in esp_spiffs_init()
249 efs->cache, efs->cache_sz, spiffs_api_check); in esp_spiffs_init()
252 ESP_LOGW(TAG, "mount failed, %i. formatting...", SPIFFS_errno(efs->fs)); in esp_spiffs_init()
253 SPIFFS_clearerr(efs->fs); in esp_spiffs_init()
254 res = SPIFFS_format(efs->fs); in esp_spiffs_init()
256 ESP_LOGE(TAG, "format failed, %i", SPIFFS_errno(efs->fs)); in esp_spiffs_init()
257 SPIFFS_clearerr(efs->fs); in esp_spiffs_init()
258 esp_spiffs_free(&efs); in esp_spiffs_init()
261 res = SPIFFS_mount(efs->fs, &efs->cfg, efs->work, efs->fds, efs->fds_sz, in esp_spiffs_init()
262 efs->cache, efs->cache_sz, spiffs_api_check); in esp_spiffs_init()
265 ESP_LOGE(TAG, "mount failed, %i", SPIFFS_errno(efs->fs)); in esp_spiffs_init()
266 SPIFFS_clearerr(efs->fs); in esp_spiffs_init()
267 esp_spiffs_free(&efs); in esp_spiffs_init()
270 _efs[index] = efs; in esp_spiffs_init()
477 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_open() local
479 int fd = SPIFFS_open(efs->fs, path, spiffs_flags, mode); in vfs_spiffs_open()
481 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_open()
482 SPIFFS_clearerr(efs->fs); in vfs_spiffs_open()
486 vfs_spiffs_update_mtime(efs->fs, fd); in vfs_spiffs_open()
493 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_write() local
494 ssize_t res = SPIFFS_write(efs->fs, fd, (void *)data, size); in vfs_spiffs_write()
496 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_write()
497 SPIFFS_clearerr(efs->fs); in vfs_spiffs_write()
505 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_read() local
506 ssize_t res = SPIFFS_read(efs->fs, fd, dst, size); in vfs_spiffs_read()
508 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_read()
509 SPIFFS_clearerr(efs->fs); in vfs_spiffs_read()
517 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_close() local
518 int res = SPIFFS_close(efs->fs, fd); in vfs_spiffs_close()
520 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_close()
521 SPIFFS_clearerr(efs->fs); in vfs_spiffs_close()
529 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_lseek() local
530 off_t res = SPIFFS_lseek(efs->fs, fd, offset, mode); in vfs_spiffs_lseek()
532 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_lseek()
533 SPIFFS_clearerr(efs->fs); in vfs_spiffs_lseek()
543 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_fstat() local
544 off_t res = SPIFFS_fstat(efs->fs, fd, &s); in vfs_spiffs_fstat()
546 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_fstat()
547 SPIFFS_clearerr(efs->fs); in vfs_spiffs_fstat()
566 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_stat() local
567 off_t res = SPIFFS_stat(efs->fs, path, &s); in vfs_spiffs_stat()
569 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_stat()
570 SPIFFS_clearerr(efs->fs); in vfs_spiffs_stat()
587 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_rename() local
588 int res = SPIFFS_rename(efs->fs, src, dst); in vfs_spiffs_rename()
590 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_rename()
591 SPIFFS_clearerr(efs->fs); in vfs_spiffs_rename()
600 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_unlink() local
601 int res = SPIFFS_remove(efs->fs, path); in vfs_spiffs_unlink()
603 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_unlink()
604 SPIFFS_clearerr(efs->fs); in vfs_spiffs_unlink()
613 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_opendir() local
619 if (!SPIFFS_opendir(efs->fs, name, &dir->d)) { in vfs_spiffs_opendir()
621 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_opendir()
622 SPIFFS_clearerr(efs->fs); in vfs_spiffs_opendir()
633 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_closedir() local
638 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_closedir()
639 SPIFFS_clearerr(efs->fs); in vfs_spiffs_closedir()
662 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_readdir_r() local
669 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_readdir_r()
670 SPIFFS_clearerr(efs->fs); in vfs_spiffs_readdir_r()
704 esp_spiffs_t * efs = (esp_spiffs_t *)ctx; in vfs_spiffs_seekdir() local
710 if (!SPIFFS_opendir(efs->fs, NULL, &dir->d)) { in vfs_spiffs_seekdir()
711 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_seekdir()
712 SPIFFS_clearerr(efs->fs); in vfs_spiffs_seekdir()
719 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_seekdir()
720 SPIFFS_clearerr(efs->fs); in vfs_spiffs_seekdir()
775 esp_spiffs_t *efs = (esp_spiffs_t *) ctx; in vfs_spiffs_utime() local
785 int ret = vfs_spiffs_update_mtime_value(efs->fs, path, t); in vfs_spiffs_utime()
788 errno = spiffs_res_to_errno(SPIFFS_errno(efs->fs)); in vfs_spiffs_utime()
789 SPIFFS_clearerr(efs->fs); in vfs_spiffs_utime()