'How to use statfs64() in a 32bit program?

This is my code:

#include <stdio.h>
#include <sys/statfs.h>

int main(int argc, char** argv)
{
    struct statfs64 mystatfs64;
    statfs64("/", &mystatfs64);  
    return 0;
}

But I get this error:

error: storage size of ‘mystatfs64’ isn’t known
warning: implicit declaration of function ‘statfs64’; did you mean ‘statfs’?

On the man page it says: The glibc statfs() and fstatfs() wrapper functions transparently deal with the kernel differences.

So I changed my code to:

#include <stdio.h>
#include <sys/statfs.h>

int main(int argc, char** argv)
{
    struct statfs mystatfs;
    statfs("/", &mystatfs);
    return 0;
}

It now compiles but sizeof(((struct statfs*)0)->f_blocks) is 4 so I can't handle big file systems.

I also tried to define __USE_LARGEFILE64 and __USE_FILE_OFFSET64 without any success.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source