首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >读取inode返回无效数据

读取inode返回无效数据
EN

Stack Overflow用户
提问于 2010-12-06 04:04:59
回答 1查看 913关注 0票数 2

我正在尝试编辑一些inode数据。但是,当我读取任何inode时,我只能得到0或无效数据。以下是我正在做的主要步骤:

代码语言:javascript
复制
//reading, say inode number 15 - it belongs to group 0, and it's a valid inode  
int inode_no=15
//buffer to hold inode structure  
struct ext2_inode inode_buffer_test1;
//points to the start of group descriptor structure. It is correct, I have validated the results with dumpe2fs.  
struct ext2_group_desc *grpdesc;  
//file descriptor of a device file holding ext2 FS, opened in O_RDONLY mode  
int fd; 

...

lseek64(fd,(long long)grpdesc[0].bg_inode_table*BLOCK_SIZE + sizeof(struct ext2_inode)*(inode_no-1),SEEK_SET);  
read(fd,&inode_buffer_test1,sizeof(struct ext2_inode));  
printf("file size=%d, blocks=%d\n",inode_buffer_test1.i_size,inode_buffer_test1.i_blocks);  

对于其他inode,我得到的只是零个或有时无效的数据。我用从"ls -i filename“命令得到的不同inode编号进行了测试,并用"stat filename”验证了数据。但是,组描述符是正确的,inode表的位置(使用dumpe2fs验证)也是正确的。

我还尝试使用"lde“工具(lde -i 15 /dev/sdb1)获取inode信息。它还会给出无效数据。请让我知道我在这里错过了什么。

提前谢谢你,马利哈

EN

回答 1

Stack Overflow用户

发布于 2010-12-06 04:13:39

BLOCK_SIZE是正确的吗?我将验证偏移量计算结果是否与使用od显示的结果一致。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4360867

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档