-
Notifications
You must be signed in to change notification settings - Fork 937
Open
Labels
needs investigationno idea what is wrongno idea what is wrong
Description
Hi dear littlefs developers.
I am creating a file in a folder. I am writing data to this file and I am able to close the file successfully. But my code sometimes freezes on "lfs_dir_orphaningcommit" function while creating the file.
uint8_t lfs_read_buf[256];
uint8_t lfs_prog_buf[256];
// configuration of the filesystem is provided by this struct
const struct lfs_config cfg = {
// block device operations
.read = user_provided_block_device_read,
.prog = user_provided_block_device_prog,
.erase = user_provided_block_device_erase,
.sync = user_provided_block_device_sync,
// block device configuration
.read_size = 256,
.prog_size = 256,
.block_size = 4096,
.block_count = 8192,
.cache_size = 256,
.lookahead_size = 256,
.block_cycles = 500,
.read_buffer = lfs_read_buf,
.write_buffer = lfs_prog_buf,
};
int fileCreate(char *fileName, uint8_t *data, int len)
{
int err = lfs_file_open(&lfs, &file, "../123456789/file1234.f", LFS_O_RDWR | LFS_O_CREAT);
if(err)
return err;
err = lfs_file_rewind(&lfs, &file);
if(err)
return err;
err = lfs_file_write(&lfs, &file, data, len);
if(err)
return err;
return lfs_file_close(&lfs, &file);
}
File Create
fileCreate("../123456789/file1234.f", writeBuf, strlen(writeBuf));
Code in infinite loop
static int lfs_dir_orphaningcommit(lfs_t *lfs, lfs_mdir_t *dir,
const struct lfs_mattr *attrs, int attrcount) {
// check for any inline files that aren't RAM backed and
// forcefully evict them, needed for filesystem consistency
for (lfs_file_t *f = (lfs_file_t*)lfs->mlist; f; f = f->next) {
if (dir != &f->m && lfs_pair_cmp(f->m.pair, dir->pair) == 0 &&
f->type == LFS_TYPE_REG && (f->flags & LFS_F_INLINE) &&
f->ctz.size > lfs->cfg->cache_size) {
int err = lfs_file_outline(lfs, f);
if (err) {
return err;
}
err = lfs_file_flush(lfs, f);
if (err) {
return err;
}
}
}
.
.
.
}
I will be glad if you help.
Metadata
Metadata
Assignees
Labels
needs investigationno idea what is wrongno idea what is wrong