I have gone through the code of inode in linux kernel code but I am unable to figure where are the data pointers in inode. I know that there are 15 pointers [0-14] out of which 12 are direct, 1 single indirect, 1 double indirect and 1 triple indirect.
Can some one please locate these data members. Also please specify how you located these as I have searched on google many time with different key words but all in vain.
It is up to a specific file system to access its data, so there’s no “data pointers” in general (some file systems may be virtual, that means generating their data on the fly or retrieving it from network).
If you’re interested in
ext4, you can look up the ext4-specific inode structure (struct ext4_inode) infs/ext4/ext4.h, where data of an inode is indeed referenced by indices of 12 direct blocks, 1 of single indirection, 1 of double indirection and 1 of triple indirection.This means that blocks [0..11] of an inode’s data have numbers
e4inode->i_block[0/1/.../11], wherease4inode->i_block[12]is a number of a block which is filled with data block numbers itself (so it holds indices of inode’s data blocks in range [12, 12 + fs->block_size / sizeof(__le32)]. The same trick is applied toi_block[13], only it holds double-indirected indices (blocks filled with indices of blocks that hold list of blocks holding the actual data) starting from index12 + fs->block_size / sizeof(__le32), andi_block[14]holds triple indirected indices.