Orphaned Response
phil at brl-tgr.UUCP
phil at brl-tgr.UUCP
Thu Jul 11 07:25:00 AEST 1985
>> 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 University
<phil at Rice.arpa>
or, for the daring: <phil at Rice.edu>
More information about the Comp.unix.wizards
mailing list