Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  warl0ck Oct 14 '12 at 2:06
    
warl0ck, what do you mean by "read raw data from disks"? –  Cypress Frankenfeld Oct 14 '12 at 18:30
    
Yes, that's true, maybe I misunderstood the question.... –  warl0ck Oct 14 '12 at 23:37

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

Did you try baobab or filelight ?

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.