static s32_t failfs_erase(u32_t addr, u32_t size) { struct mount_info *m = &s_fsm; dprintf(("failfs_erase %d @ %d\n", (int) size, (int) addr)); if (m->formatting) { /* During formatting, the file is brand new and has just been erased. */ return SPIFFS_OK; } return fs_switch_container(m, addr, size) == 0 ? SPIFFS_OK : SPIFFS_ERR_ERASE_FAIL; }
static s32_t failfs_write(spiffs *fs, u32_t addr, u32_t size, u8_t *src) { struct mount_info *m = (struct mount_info *) fs->user_data; _i32 r; DBG(("failfs_write %d @ %d, cidx %d # %llu, fh %d, valid %d, rw %d", (int) size, (int) addr, m->cidx, m->seq, (int) m->fh, m->valid, m->rw)); if (!m->valid) return SPIFFS_ERR_NOT_WRITABLE; if (!m->rw) { /* Remount rw. */ if (fs_switch_container(m, 0, 0) != 0) return SPIFFS_ERR_NOT_WRITABLE; } r = sl_FsWrite(m->fh, addr, src, size); DBG(("write %d", (int) r)); m->last_write = mg_time(); return (r == size) ? SPIFFS_OK : SPIFFS_ERR_NOT_WRITABLE; }
static s32_t failfs_write(u32_t addr, u32_t size, u8_t *src) { struct mount_info *m = &s_fsm; _i32 r; dprintf(("failfs_write %d @ %d, cidx %d # %llu, fh %d, valid %d, rw %d\n", (int) size, (int) addr, m->cidx, m->seq, (int) m->fh, m->valid, m->rw)); if (!m->valid) return SPIFFS_ERR_NOT_WRITABLE; if (!m->rw) { /* Remount rw. */ if (fs_switch_container(m, 0, 0) != 0) return SPIFFS_ERR_NOT_WRITABLE; } r = sl_FsWrite(m->fh, addr, src, size); dprintf(("write %d\n", (int) r)); return (r == size) ? SPIFFS_OK : SPIFFS_ERR_NOT_WRITABLE; }
static s32_t failfs_erase(spiffs *fs, u32_t addr, u32_t size) { struct mount_info *m = (struct mount_info *) fs->user_data; DBG(("failfs_erase %d @ %d", (int) size, (int) addr)); return fs_switch_container(m, addr, size) == 0 ? SPIFFS_OK : SPIFFS_ERR_ERASE_FAIL; }