rcp

Wayne Hathaway wayne at ames-nas.arpa
Wed Mar 12 08:33:23 AEST 1986


Regarding the BSD "feature" of trashing files if you happen
to forget which host you are on and do an rcp of a file onto
itself:

We (Sterling Software, formerly Informatics) are developing
networking software for NASA Ames based on 4.2BSD, and we
recognized very early that users would be most unhappy with
the virgin BSD behavior.  Our first "fix" was to compare the
local hostname (from gethostname()) against the colon name
and all its aliases (from gethostbyname()).  For singly
homed hosts, this is reasonably effective.

The better fix, which is currently being installed, relates
to the uid/gid mapping capability we implemented as part of
our Newcastle Connection-based distributed file system
(described in an earlier mail to this group).  The problem
was that uid/gid mappings should be based on MACHINE, rather
than PATH (which unfortunately is what Internet names and
addresses refer to).  That is, it shouldn't matter that a
connection came over the HYPERchannel, the Ethernet, or
through the IMP -- what counts is the source machine itself.
To facilitate this type of mapping, we (re)introduced the
concept of machine-id, or mid.

Now, with every host in our network assigned a unique mid,
it is an easy matter to fetch the mids of both files, and
thus protect against the BSD behavior.

Also note that this fix is needed for cp itself in a
distributed file system environment, particularly since we
allow either hostname or alias to be used in remote
pathnames (which all start with /r/).  Thus our version of
Newcastle handles things like

    cp /r/cramden/etc/hosts /r/ralphie-boy/etc/hosts

where "ralphie-boy" is an alias for "cramden."  This was a
trivial change to mv.c to check for identical mids as well
as identical device and inode numbers, using a new pseudo-
syscall "statmid" which returns a file's mid ("pseudo-
syscall" because it is done in the C library; our
distributed file system requires no kernel changes).

And a side comment/question:  The "hostid" concept of 4.2BSD
would seem to have been a start at "machine-ids", but then
they went and equated it with Internet address (which of
course completely defeats the benefits).  Anybody know what
Berkeley had in mind for "hostid"?


Wayne Hathaway    wayne at ames-nas.arpa
Sterling Software/Informatics


PS:  Or is that "kramden"?



More information about the Comp.unix.wizards mailing list