UFS Inode Direct Blocks

Eric Sheridan esheri3 at tiger.towson.edu
Tue Oct 25 20:10:38 PDT 2005


Hello Everyone:

My name is Eric and I am working on a project which traverses the inodes of
the disk in order to map out the file system. I am able to read in the
superblock with the SBLOCK_UFS2 offset. I am able to read in any disk inode
using the following offsets:

ib = fsbtodb(superblock, itod(superblock, i_num));
lseek(fd, ib*DEV_BSIZE, SEEK_SET);
read(fd, buffer, sizeof(buffer));
d = (struct ufs2_dinode *)buffer + itoo(superblock, i_num);

*Note* I have defines for the itoo and itod to appropriate ino_to_*'s

However, given the dinode, I do not know how to seek to the direct blocks of
the dinode. My question is how do I seek to these direct blocks stored in
di_db[] using all of these available macros? What is stored in these data
blocks? If the inode represents a directory, then do the data blocks contain
"struct ufs2_direct"s? If I am able to get file names from directory inodes,
then I will be able to map out every file on the system. This is my first
post, so I appologize for being either too vague or too verbose. Thank you
everyone in advance for your help.

-Eric Sheridan


More information about the freebsd-fs mailing list