Skip to content

Instantly share code, notes, and snippets.

@nicdoye
Created January 28, 2013 10:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
List number of inodes for file system and how many spare.
#include <stdio.h>
#include <stdlib.h>
#include <sys/statvfs.h>
int main(int argc, char **argv)
{
struct statvfs _statvfs;
if ( argc != 2 )
{
printf("Just the one argument please\n");
exit(1);
}
if ( statvfs( argv[1] , &_statvfs ) != 0 ) {
printf("Something went wrong. Is %s a valid mount point?\n", argv[1]);
exit(2);
}
printf("inodes\t%lld\nfree\t%lld\nufree\t%lld\n",
(long long) _statvfs.f_files,
(long long) _statvfs.f_ffree,
(long long) _statvfs.f_favail );
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment