inode数据结构中的数据指针 [英] data pointers in inode data structure

查看:161
本文介绍了inode数据结构中的数据指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过Linux内核代码中的inode代码,但是我无法弄清楚inode中的数据指针在哪里.我知道有15个指针[0-14],其中12个是直接指针,1个单间接指针,1个双间接指针和1个三重间接指针.

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.

有人可以找到这些数据成员吗?另外,请指定您的定位方式,因为我在Google上搜索了很多次,但关键词却是徒劳的.

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).

如果您对ext4感兴趣,可以在fs/ext4/ext4.h中查找ext4特定的inode结构(struct ext4_inode),其中inode的数据确实由12个直接块的索引引用,其中1个为单次间接,1次双重间接和1次三重间接.

If you're interested in ext4, you can look up the ext4-specific inode structure (struct ext4_inode) in fs/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.

这意味着inode数据的块[0..11]的编号为e4inode->i_block[0/1/.../11],而e4inode->i_block[12]是其自身已填充数据块编号的块的编号(因此它保存了inode数据块的索引范围为[12,12 + fs-> block_size/sizeof(__ le32)].对i_block[13]应用相同的技巧,只有它包含双间接索引(填充有块索引的块,这些块的索引包含保存实际块的列表).数据)从索引12 + fs->block_size / sizeof(__le32)开始,而i_block[14]保留三重间接索引.

This means that blocks [0..11] of an inode's data have numbers e4inode->i_block[0/1/.../11], whereas e4inode->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 to i_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 index 12 + fs->block_size / sizeof(__le32), and i_block[14] holds triple indirected indices.

这篇关于inode数据结构中的数据指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆