1

I am trying to traverse all of the allocated inodes in the filesystem for xv6 and I want to get the dinode of the root directory and go from there, but I have had trouble getting this to work. I tried using 'dirlookup()' but no matter what I imported I would get errors saying that that the function is not defined.

bs7280
  • 1,074
  • 3
  • 18
  • 32

1 Answers1

2

I know i'm late to the answer but here goes. An inode number can be gotten from the stat() command, and the root directory that you are currently in is referenced by "." just as your parent directory is ".." here is a short example of how you should be able to get the inode number of root directory. Keep in mind I don't have time to test this right but it is what I remember from using xv6

uint getRootInode() {
     struct stat sb;
     stat(".", &sb);
     return sb.ino;
}

EDIT:
Also dirlookup() is defined defs.h and implemented in fs.c

Zannith
  • 429
  • 4
  • 21