yamt commented on issue #15840: URL: https://github.com/apache/nuttx/issues/15840#issuecomment-2661892087
> > how about `fsync(fileno(fp))`? > > Thank you! I think this should solve my issue! > > However, my other question I am still wondering about: when during normal file operations can I expect the file to be synced to the "disk" (in this case SD card)? Regular `fopen`, `fwrite`, `fclose` sequence still leaves a completely blank log file. Surely `fclose` should trigger a synchronization to make sure no information is lost. How come after running `fwrite` for many iterations there is still no file contents actually written to the card? api-wise, none of these operations guarantee to preserve data on ungraceful shutdown events like power loss. implementation-wise, usually these operations at least sometimes flush data to the underlying device. re-reading your description, > I have also tried limiting the loop to 10 iterations, then closing the file with fclose after the loop and then cutting power. The file still remains empty. this part looks weird to me because, iirc, littlefs close() commits the modifications. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org