Skip to content
Advertisement

C Linux Check free space in mount

When I running df -h I can see that in /dev I use 6M and the size is 40M , and Available size is 34M .

How can I get this information with c code?

Advertisement

Answer

From here:

Use the statvfs API:

JavaScript

and the prototype of the statvfs is

JavaScript

The results will be filled to the buf statvfs struct:

JavaScript

The return type is:

On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

Also have a look at the man3 manpage of the statvfs command for more and detailed information.

Advertisement