iノードデータを編集しようとしています。ただし、inode を読み取ると、ゼロまたは無効なデータしか得られません。私がやっていることの主なステップは次のとおりです。
//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 情報を取得しようとしました。また、無効なデータも提供します。ここで何が欠けているか教えてください。
前もって感謝します, マリハ