🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Francois Pinard Fri, 01 Jan 1993 18:52
Problem with cp -pf and hard links (bis)
#1226
Author: Francois Pinard
Date: Fri, 01 Jan 1993 18:52
64 lines
2421 bytes
Here is a script, hopefully reproducible, demonstrating the problem I
recently described in a previous message.  Before trying it, execute
first the equivalent of (I'm using bash):

	cp() { /usr/local/gnubin/cp -i $*; }
	rm() { /usr/local/gnubin/rm -i $*; }

If I copy x3 over x1, x2 will be changed too (this is nice):

~) echo a > x1
~) ln x1 x2
~) echo b > x3
~) v x*
-rw-r-----   2 pinard   other           2 Jan  1 13:39 x1
-rw-r-----   2 pinard   other           2 Jan  1 13:39 x2
-rw-r-----   1 pinard   other           2 Jan  1 13:40 x3
~) cp -p x3 x1
/usr/local/gnubin/cp: overwrite `x1'? y
~) v x*
-rw-r-----   2 pinard   other           2 Jan  1 13:40 x1
-rw-r-----   2 pinard   other           2 Jan  1 13:40 x2
-rw-r-----   1 pinard   other           2 Jan  1 13:40 x3
~) cat x2
b


Clean up before retrying:

~) rm x*
/usr/local/gnubin/rm: remove `x1'? y
/usr/local/gnubin/rm: remove `x2'? y
/usr/local/gnubin/rm: remove `x3'? y


I have to revert to using -f for the following to work, the hardlink
relationship is broken.  Copying x3 over x1 does not change x2 (this
is sad):

~) echo a > x1
~) ln x1 x2
~) chmod 440 x1
~) echo b > x3
~) v x*
-r--r-----   2 pinard   other           2 Jan  1 13:41 x1
-r--r-----   2 pinard   other           2 Jan  1 13:41 x2
-rw-r-----   1 pinard   other           2 Jan  1 13:41 x3
~) cp -p x3 x1
/usr/local/gnubin/cp: overwrite `x1', overriding mode 0440? y
/usr/local/gnubin/cp: cannot create regular file `x1': Permission denied
~) cp -pf x3 x1
~) v x*
-rw-r-----   1 pinard   other           2 Jan  1 13:41 x1
-r--r-----   1 pinard   other           2 Jan  1 13:41 x2
-rw-r-----   1 pinard   other           2 Jan  1 13:41 x3
~) cat x2
a
~) cat x1
b
~) 

-- 
Franc,ois Pinard       ``Happy GNU Year!''      pinard@iro.umontreal.ca
(514) 588-4656                                   ...!uunet!iros1!pinard
About the League for Programming Freedom?  Email me or lpf@uunet.uu.net
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads