I'm trying to create a graph of the distribution of file sizes on my ext4 system. I'm trying to write a script to scrape this information from my computer somehow. I don't care where the files are stored in the directory structure, only how much space each takes up. I know file sizes are stored in the inode metadata, and it seems like it might be pretty fast to read through the inode table, if such a thing exists. Does anyone know of a C API for accessing the size of files, or reading directly from the inode table? Does anyone know where the inode table is stored?

  • It would be a waste of time if you try to read raw data from disks. Otherwise use the C API stat would just do the job.
    – daisy
    Oct 14, 2012 at 2:06
  • warl0ck, what do you mean by "read raw data from disks"? Oct 14, 2012 at 18:30
  • Yes, that's true, maybe I misunderstood the question....
    – daisy
    Oct 14, 2012 at 23:37

2 Answers 2


If you want a C API, you're going to end up with GNU nftw, the GNU file tree walk. DON'T fool yourself into using plain old ftw, you will get inaccurate data. You'll need to write a "per file" function that uses the struct stat that nftw passes into the "per file" function. You can have the "per file" function put file sizes in buckets, or just print out the file size, and then put the numbers in buckets some other way.


Did you try baobab or filelight ?

  • There are more entries listed here: makeuseof.com/tag/…. I personally like gdmap.
    – jordanm
    Oct 13, 2012 at 20:26
  • does du -a give what you want?
    – Julian
    Oct 13, 2012 at 21:36
  • Thanks for the suggestions, but I'm looking to code something, not use a GUI. Oct 14, 2012 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .