I want to find out how many disk blocks are used by only data (and not metadata) by a file.
But as far as I can tell, if the file has holes, then there is no way to know this.
You can find out the logical size of the file (physical size + hole blocks).
You can get the physical size of the file (data + metadata).
But no matter what calculation you do or whatever program you write, you cannot get the blocks occupied by data.
hmm, I am sorry, by metadata I think I meant Indirect blocks
what I mean is, whatever shell cmds I have to get a file size.. they will give me the total disk space occuiped by the file (data + other stuff). But I want to know whats the space occupied by data only.
ls -ls for example...
Here 104 is the total physical disk space occupied by the file. As far as I understand this includes space occupied by data, metadata, Indirect blocks, (Inode) etc etc...
Sure, a file system level program might be able to give the answer.. but how can a user level program find out the number of data blocks ?
(A program might read the file and calculate the number of blocks read, but if the file has holes.. it will read those too.. )