How do I read and traverse inodes
Posted
by
Eric Fossum
on Stack Overflow
See other posts from Stack Overflow
or by Eric Fossum
Published on 2011-06-09T02:52:33Z
Indexed on
2012/12/15
23:04 UTC
Read the original article
Hit count: 231
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);
© Stack Overflow or respective owner