Article View: gnu.utils.bug
Article #1226Problem with cp -pf and hard links (bis)
From: Francois Pinard
Date: Fri, 01 Jan 1993 18:52
Date: Fri, 01 Jan 1993 18:52
64 lines
2421 bytes
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
Technical Details
Message-ID:
<9301011852.AA06869@icule.UUCP>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!icule.UUCP!pinardShow Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!icule.UUCP!pinard From: pinard@icule.UUCP (Francois Pinard) Subject: Problem with cp -pf and hard links (bis) Message-ID: <9301011852.AA06869@icule.UUCP> Sender: gnulists@ai.mit.edu Reply-To: pinard@iro.umontreal.ca Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 1 Jan 1993 18:52:13 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 65