My task is to implement the Unix command pwd using inodes in C. I have figured out how I can go back recursively until the inode of '..' is the same as the inode of '.'. The problem I am having now is that I don't know how to get the directory name of '..'. Using the stat struct I can get everything about the file like size, inode, etc but I need to get the file so I can make it output something like:
/home/GONZAGA/tcosentino/documents/OS
How can I get these directory names?
I have the stat struct so it can print out this so far:
[tcosentino@ada2 OS]$ ./a.out .
filename: .
device: 64768
inode: 55804237
protection: 40755
number of hard links: 5
user ID of owner: 81963576
group ID of owner: 501
device type (if inode device): 0
total size, in bytes: 4096
blocksize for filesystem I/O: 4096
number of blocks allocated: 8
time of last access: 1354817261 : Thu Dec 6 10:07:41 2012
time of last modification: 1354817249 : Thu Dec 6 10:07:29 2012
time of last change: 1354817249 : Thu Dec 6 10:07:29 2012