On Fri, May 28, 2021 at 8:21 PM Flavio Castro Alves Filho < flavio.al...@gmail.com> wrote:
> Hello, > > I am using LittleFS to store information on an external dataflash. > > I need to know if the memory is full. I saw that the nsh provides the > df command, which as far as I understood is a cat for /proc/fs/usage > file. > > In my code, I could see the LFS message indicating LFS_ERR_NOSPC, > which is an error message indicating no more space when writing files. > But the return from the fwrite call is OK (indicating the number of > written bytes) :-| > > This behaviour may be due to LittleFS not really committing the change to disk until you call flush or close the file. > Is /proc/fs/usage available for LittleFS? Is there any way to get the > disk space programmatically? > You could call statfs and check f_bavail/f_bfree field: https://github.com/apache/incubator-nuttx/blob/master/fs/littlefs/lfs_vfs.c#L1148-L1184 > > Best regards, > > Flavio > > -- > Flavio de Castro Alves Filho > > flavio.al...@gmail.com > Twitter: http://twitter.com/#!/fraviofii > LinkedIn profile: www.linkedin.com/in/flaviocastroalves >