Hi Janne,

...nice explanation of the known hard links.
on my system (the same holds for linux) cp and also rcp preserve hard
links unlike mv which indeed is the same as 'rm xx; scp -p /etc/passwd xx'.
Try it on your system.

Greetings,
M.Bruns

> > using ssh 3.01 on Solaris.
> > scp does not preserve hard links:
> >
> > $ cp -p /etc/group xx
> 
>       Here you copy the /etc/group file to the file xx on current
> directory.
> 
> > $ ln xx aa
> 
>       And make a hard link aa -> xx.
> 
> > $ ll aa xx
> > -rw-r--r--   2 root     other        313 Sep 24 16:04 aa
> > -rw-r--r--   2 root     other        313 Sep 24 16:04 xx
> 
>       Looks as it should. Note the number 2 afret the access rights.
> It tells that that particuar file is referenced from two locations. There
> is actually only one copy of the file on the disk, but two directory
> entries pointing to it.
>
> > $ scp -p /etc/passwd xx
> 
>       Now you copy /etc/passwd and _overwrite_ the file xx. This in
> effect is the same as 'rm xx; scp -p /etc/passwd xx'. What it does, is
> decreases the reference count to the copy of /etc/group file on the disk,
> deletes the xx directory entry and creates a new entry, copying the
> /etc/passwd file to it (or to a location on the disk pointed to by it).
> 
> > $ ll aa xx
> > -rw-r--r--   1 root     other        313 Sep 24 16:04 aa
> > -r--r--r--   1 root     other        414 May  9 11:16 xx
> 
>       And after all that, the directory looks exactly as it should.
> 
>       Making hard link does not mean that all the directory entries are
> linked with each other; it only means that multiple directory entries are
> pointing to a same file on the disk. You can delete one directory entry
> without deleting the file it self (provided there is still atleast one
> directory entry pointing to the file somewhere); and you can overwrite one
> of the directory entries without overwriting the file itself.
> 
> > it's a bug for me.
> 
>       Um, no it's not. :)
> 
>       Try it with cp and it does the same thing. Overwriting does not
> modify the actual file to contain the new data; it deletes the original
> and then creates a totally new file.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to