Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!phil@RICE.ARPA From: phil@RICE.ARPA (William LeFebvre) Newsgroups: net.unix-wizards Subject: Re: inode number -> pathname? (4.2BSD) Message-ID: <11465@brl-tgr.ARPA> Date: Wed, 10-Jul-85 17:25:38 EDT Article-I.D.: brl-tgr.11465 Posted: Wed Jul 10 17:25:38 1985 Date-Received: Fri, 12-Jul-85 04:47:48 EDT Sender: news@brl-tgr.ARPA Lines: 29 >> 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 ... (this is effectively 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? Now, what would be hard would be generating the full path name for an arbitrary file given just the inode and device. The only program that can do that is find, and I strongly suspect that that will never change in the near or far future. Doing so would violate one of the founding principles of the Unix file system. But with a directory, you know that (save symbolic links) there is one unique path name for that directory. William LeFebvre Department of Computer Science Rice Universityor, for the daring: