How do I read and traverse inodes
- by Eric Fossum
I've opened the super-block and group descriptor in an EXT2 filesystem, but I don't know how to read for instance the root directory or files in it...
Here's some of what i got
fd=open("/dev/sdb2", O_RDONLY);
lseek(fd, SuperSize, SEEK_SET);
read(fd, &super_block, SuperSize);
lseek(fd, 4096, SEEK_SET);
read(fd, &groupDesc, DescriptSize);
but this next part doesn't seem to work...
lseek(fd, super_block.s_log_block_size*groupDesc.bg_inode_table, SEEK_SET);
lseek(fd, InodeSize*(EXT2_ROOT_INO-1), SEEK_CUR);
read(fd, &root, InodeSize);