Path: utzoo!attcan!uunet!decwrl!ucbvax!bloom-beacon!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: Directory traversal (crossin mount points) Keywords: Directory Traversals, Mount points Message-ID: <1990Jul2.162625.28550@athena.mit.edu> Date: 2 Jul 90 16:26:25 GMT References: <5854@aplcen.apl.jhu.edu> Sender: news@athena.mit.edu (News system) Reply-To: jik@athena.mit.edu (Jonathan I. Kamens) Organization: Massachusetts Institute of Technology Lines: 26 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