🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #1224

Problem with cp -pf and hard links

#1224
From: Francois Pinard
Date: Fri, 01 Jan 1993 16:09
38 lines
2068 bytes
This relates to GNU fileutils 3.4, installed with GNU C 1.41 under
COFF encapsulation on this 386/ix 2.0.2 system.

The problem is that cp -pf destroy the hard link relationship of the
destination file, *if* that file was not writeable before the copy.

Here is the actual case.  I have ~/gnu/distrib/texinfo.tex (call it
$DESTIN) which is hard linked with texinfo.tex files in many
directories, used for making distributions.  $DESTIN has mode 444.
(This system does not have symbolic links.)  I am now unpacking a new
GNU package which provides a newer version of texinfo.tex, and want to
update not only $DESTIN from it, but also the hardlinked instances.

For reference, I have "cp() { /usr/local/gnubin/cp -i $*; }" in my
.bashrc, so all occurrences of cp imply -i.  If I merely execute:

	cp -pf texinfo.tex $DESTIN

with $DESTIN already existing with mode 444, then $DESTIN will receive
a copy of the newer texinfo with a hard link count of 1, while the
texinfo.tex's in the distribution directories stay undisturbed.

If I rather execute:

	chmod 644 $DESTIN
	cp -pf texinfo.tex $DESTIN

then $DESTIN will retain its previous hard link count and all copies
will be updated.  This is the behaviour I am expecting.

I would certainly need a cp, and even a mv, which reliably keeps the
previous hardlink relationships of the destination file, whatever the
destination file mode was.

-- 
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: <9301011609.AA06748@icule.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!icule.UUCP!pinard

Show 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
Message-ID: <9301011609.AA06748@icule.UUCP>
Sender: gnulists@ai.mit.edu
Reply-To: pinard@iro.umontreal.ca
Organization: GNUs Not Usenet
Distribution: gnu
Date: Fri, 1 Jan 1993 16:09:22 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 39