You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticintlfs_file_flush(lfs_t*lfs, lfs_file_t*file) {
LFS_ASSERT(file->flags&LFS_F_OPENED);
......
while (file->pos<file->ctz.size) {
// copy over a byte at a time, leave it up to caching// to make this efficientuint8_tdata;
lfs_ssize_tres=lfs_file_read(lfs, &orig, &data, 1);
if (res<0) {
returnres;
}
res=lfs_file_write(lfs, file, &data, 1);
if (res<0) {
returnres;
}
// keep our reference to the rcache in syncif (lfs->rcache.block!=LFS_BLOCK_NULL) {
lfs_cache_drop(lfs, &orig.cache);
lfs_cache_drop(lfs, &lfs->rcache);
}
}
......
return0;
}
when we use lfs_file_seek to change the file->pos, it repeats reading and writing till the file->pos is equal to the file->ctz.size; any problems with my understanding?
eg: we have already created a 1MiB file, when we change the file->pos to the head, and close the file after writen a byte data 0x05, then the function lfs_file_seek takes effect, repeats 1M times to read and write, it may take a long time waiting, does this design reasonable?
Ignore my poor English. Hope to get some suggestions. thanks
The text was updated successfully, but these errors were encountered:
when we use lfs_file_seek to change the file->pos, it repeats reading and writing till the file->pos is equal to the file->ctz.size; any problems with my understanding?
eg: we have already created a 1MiB file, when we change the file->pos to the head, and close the file after writen a byte data 0x05, then the function lfs_file_seek takes effect, repeats 1M times to read and write, it may take a long time waiting, does this design reasonable?
Ignore my poor English. Hope to get some suggestions. thanks
The text was updated successfully, but these errors were encountered: