Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.unix-wizards Subject: Re: inode number -> pathname? (4.2BSD) Message-ID: <812@umcp-cs.UUCP> Date: Thu, 11-Jul-85 19:27:04 EDT Article-I.D.: umcp-cs.812 Posted: Thu Jul 11 19:27:04 1985 Date-Received: Sat, 13-Jul-85 10:32:26 EDT References: <11465@brl-tgr.ARPA> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 37 >>> I am looking for a good way to generate the full path name of a directory, >>> given only its inode number (plus the device number of its filesystem). >>> The 'obvious' solution is ... (what "ncheck" does). >> Not only is it the obvious solution, it's the only solution. No version of >> UNIX currently in existence or coming out in the near future (nor, I >> suspect, any version you're likely to see) makes it any easier. > I disagree! If it were possible to set the current working directory > to a given inode and device, then pwd would give you the answer. All > the permission information, and even the bit denoting whether or not > this inode refers to a directory is stored in the inode, and can easily > be checked in such a call. Putting such a call in would be easy. Just > do what "chdir" (well, actually "chdirec" in 4.2) does after it calls > "nami". Why is this hard? It's "hard" because the difference between chdir and set_my_cdir_inode is that chdir checks permissions along the *entire pathname* leading to the ultimate inode that will sit in u.u_cdir. (Of course you could restrict the set_my_cdir_inode syscall to the super user....) Even putting code in the kernel to do what pwd does, and making it check permissions on all the parent directories, wouldn't be right as when you log in you get to your home directory by a chdir by uid 0, so there's no guarantee that any higher level directories are accessible (anymore). > Now, what would be hard would be generating the full path name for > an arbitrary file given just the inode and device. ... But with > a directory, you know that (save symbolic links) there is one unique > path name for that directory. Actually, you don't "know" it, but you sure hope it's true.... -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@maryland