I'm playing a bit with xv6, a modern implementation of Unix version 6.
For my first hack, I wanted to implement the simple getcwd syscall, but I'm a bit lost as to which level of abstraction I should use.
- Should I use the
struct fileinterface? - Or maybe the
struct inodeinterface? - For what matters, it seems it could even be implemented purely in userland.
I started implementing it with struct inode manipulations. My naive idea was to retrieve the proc->cwd, then readi() its second entry (..), scan it to retrieve my previous inum, and so on recursively until I hit the root.
Doesn't seem very performant, but that will fit for a first hack.
My problem though is that I need fs.c:iget() to retrieve a struct inode from the inums I get in the dirents. I've noticed that iget() is static in fs.c and not declared in defs.h which annoys me a bit, but I can't find the reason why.
So, this is my question. Why is it that iget() was deliberately hidden from the rest of the kernel?