Need to find name of server which owns a file
Brent Chapman
capmkt!brent at uunet.uu.net
Wed Jun 28 03:32:59 AEST 1989
# We are building some network program-maintenance tools. We need a way to
# associate a unique label with each file in the network (preferably, with
# every file in the universe). From our (fairly ignorant) point of view, we
# think we would have what we want if we knew how to generate, given a
# pathname on some node, a string of the form
#
# (server-node-id):(true-pathname-on-server).
#
# This is based on our understanding that every node in the galaxy has a
# unique id (associated with its network address) and that every file in the
# galaxy has a server on which it resides and a `true' physical path on some
# device owned by the server. Our problems are:
#
# (1) we aren't 100% sure this is correct. can anyone tell us?
It's not. Links to a file (so-called "hard" links, as opposed to the more
common (these days, anyway) "symbolic" links) are indistinguishable from
the "original" name of a file, thus making it impossible to determine the
"one true name" of the file (there isn't one).
Creating a named file involves two steps: creating the file itself, and
creating a link with the file's name from the file's parent directory to
the file. There's nothing special about the first, second, n-th link to a
file, and no way to determine that a given link _is_ the first, second, or
n-th. The only thing the filesystem keeps track of is how many links
still point to the actual data; when the number of links drops to 0, the
last link to the data has been removed, and the data is deleted.
Let's say I have a directory called "d" containing a file called "a". If
I do "cd d ; ln a b", I have just created a new link to the same file; the
new link is called "b". "a" and "b" are now totally indistinguishable as
links to the file; I can reference the file by either (or both), and I can
delete either and still reference the file by the other.
If all I have is the raw data of a file, and no idea what the file is
called, then I have what's called an "i-node number". To find a name for
the file (or all the names for a file), I have to search all the
directories for the filesystem the file is in, looking for this i-node
number name in each directory (a directory is basicly just a map between
link names and inode numbers). Like I said, there is no way of knowing
which of the possibly many different names that map to a given i-node
number is the "real" name of the file; there is no way to tell which was
"first" or "last", and they are all equally "real".
-Brent
--
Brent Chapman Capital Market Technology, Inc.
Computer Operations Manager 1995 University Ave., Suite 390
brent at capmkt.com Berkeley, CA 94704
{apple,lll-tis,uunet}!capmkt!brent Phone: 415/540-6400
More information about the Comp.sys.sun
mailing list