trw@aplcen.apl.jhu.edu (Weil timothy) (06/30/90)
I'm writing a simple program to emulate the 'pwd' command that traverses from the current directory to the ROOT_INODE via a simple statement like - while (this_dir_inode != ROOT_INO) chdir .. match this_dir_inode in parent_directory .... et cetra Question: - since there are repitions of ROOT_INODE (#2) across file system mount points, how can I distinguish the ROOT_INODE for '/' from '/usr' or '/usr/users' ? Hope this isn't too confusing.
jik@athena.mit.edu (Jonathan I. Kamens) (07/02/90)
In article <5854@aplcen.apl.jhu.edu>, trw@aplcen.apl.jhu.edu (Weil timothy) writes: |> I'm writing a simple program to emulate the 'pwd' command |> that traverses from the current directory to the ROOT_INODE |> via a simple statement like - |> |> while (this_dir_inode != ROOT_INO) |> chdir .. |> match this_dir_inode in parent_directory |> .... |> et cetra |> |> Question: - since there are repitions of ROOT_INODE (#2) |> across file system mount points, how can I distinguish the |> ROOT_INODE for '/' from '/usr' or '/usr/users' ? The way to tell if you've reached the actual root of the local filesystem, or just some root inode on a remote filesystem mounted somewhere in your local filesystem is to check if the inode and device numbers of "." and ".." in the directory are the same. If they are, then you're at the root of the filesystem. Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8495 Home: 617-782-0710