git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Cross-directory hard links
@ 2009-05-11 10:41 Cedric Staniewski
  2009-05-11 11:02 ` [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile Johannes Schindelin
  2009-05-11 16:40 ` Cross-directory hard links Tony Finch
  0 siblings, 2 replies; 6+ messages in thread
From: Cedric Staniewski @ 2009-05-11 10:41 UTC (permalink / raw)
  To: git

Hi everybody,

git commit 6a0861 [1] made bin/git the target of the builtins hard links which
results in 'cross-directory' hard links. While the Makefile always works fine
for the local installation via 'make install', these links can raise trouble
when installing git via package manager.

The problem only occurs on systems where git's bin and lib directories will be
installed on different file systems, e.g. if /usr and /usr/lib are different
mount points. If you attempt to install a git package which was built with
DESTDIR=/usr and contains such hard links, tar will fail to extract either
bin/git or the builtins (depending on how tar resolves the hard links)
complaining about a 'Invalid cross-device link'.

I know such a setup is probably quite rare, but the problem can easily be fixed
by always copying bin/git to lib/git-add instead of hard linking it.

Cheers,
Cedric

[1]
http://git.kernel.org/?p=git/git.git;a=commit;h=6a0861a8a3295395238c8126c6e74c66b715c595

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile
  2009-05-11 10:41 Cross-directory hard links Cedric Staniewski
@ 2009-05-11 11:02 ` Johannes Schindelin
  2009-05-11 16:29   ` Cedric Staniewski
  2009-05-11 16:40 ` Cross-directory hard links Tony Finch
  1 sibling, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2009-05-11 11:02 UTC (permalink / raw)
  To: Cedric Staniewski; +Cc: git


When the installed programs are tar'ed up and installed on a system where
bin/ and libexec/git-core/ live on different file systems, we do not want
libexec/git-core/git-* to be hardlinks to bin/git.

Noticed by Cedric Staniewski.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	On Mon, 11 May 2009, Cedric Staniewski wrote:

	> git commit 6a0861 [1] made bin/git the target of the builtins 
	> hard links which results in 'cross-directory' hard links. While the 
	> Makefile always works fine for the local installation via 'make 
	> install', these links can raise trouble when installing git via
	> package manager.

	I do not understand how this commit could be responsible, but here 
	is an attempt to fix things.

 Makefile |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile
index 6e21643..b00e22d 100644
--- a/Makefile
+++ b/Makefile
@@ -175,6 +175,9 @@ all::
 # Define OBJECT_CREATION_USES_RENAMES if your operating systems has problems
 # when hardlinking a file to another name and unlinking the original file right
 # away (some NTFS drivers seem to zero the contents in that scenario).
+#
+# Define NO_CROSS_DIRECTORY_HARDLINKS if you plan to distribute the installed
+# programs as a tar, where bin/ and libexec/ might be on different file systems.
 
 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -1549,6 +1552,7 @@ endif
 	bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \
 	execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \
 	{ $(RM) "$$execdir/git-add$X" && \
+		test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \
 		ln "$$bindir/git$X" "$$execdir/git-add$X" 2>/dev/null || \
 		cp "$$bindir/git$X" "$$execdir/git-add$X"; } && \
 	{ for p in $(filter-out git-add$X,$(BUILT_INS)); do \
-- 
1.6.3.49.g4d15.dirty

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile
  2009-05-11 11:02 ` [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile Johannes Schindelin
@ 2009-05-11 16:29   ` Cedric Staniewski
  2009-05-11 19:08     ` Johannes Schindelin
  0 siblings, 1 reply; 6+ messages in thread
From: Cedric Staniewski @ 2009-05-11 16:29 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
> 	I do not understand how this commit could be responsible, but here 
> 	is an attempt to fix things.

The important difference is that before this commit, git-add was
hardlinked to a file outside of DESTDIR. Thus, when the build directory
was removed or you tar'ed DESTDIR, git-add was just a regular file and
all the other builtins were hardlinked to it.

Behavior before commit:
$ touch git git-add && mkdir bin libexec && cp git bin &&
ln git-add libexec/ &&                      ###  the relevant line
tar caf git.tar.gz bin libexec && tar tfv git.tar.gz

bin/
bin/git
libexec/
libexec/git-add


Behavior after commit:
$ touch git git-add && mkdir bin libexec && cp git bin &&
ln bin/git libexec/git-add &&               ### the relevant line
tar caf git.tar.gz bin libexec && tar tfv git.tar.gz

bin/
bin/git
libexec/
libexec/git-add link to bin/git

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Cross-directory hard links
  2009-05-11 10:41 Cross-directory hard links Cedric Staniewski
  2009-05-11 11:02 ` [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile Johannes Schindelin
@ 2009-05-11 16:40 ` Tony Finch
  1 sibling, 0 replies; 6+ messages in thread
From: Tony Finch @ 2009-05-11 16:40 UTC (permalink / raw)
  To: Cedric Staniewski; +Cc: git

On Mon, 11 May 2009, Cedric Staniewski wrote:
>
> The problem only occurs on systems where git's bin and lib directories will be
> installed on different file systems, e.g. if /usr and /usr/lib are different
> mount points.

Some filesystems (a.g. AFS) do not support cross-directory hardlinks
even when they are under the same mount point.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile
  2009-05-11 16:29   ` Cedric Staniewski
@ 2009-05-11 19:08     ` Johannes Schindelin
  2009-05-11 20:05       ` Cedric Staniewski
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2009-05-11 19:08 UTC (permalink / raw)
  To: Cedric Staniewski; +Cc: git

Hi,

On Mon, 11 May 2009, Cedric Staniewski wrote:

> Johannes Schindelin wrote:
> > 	I do not understand how this commit could be responsible, but here 
> > 	is an attempt to fix things.
> 
> The important difference is that before this commit, git-add was
> hardlinked to a file outside of DESTDIR. Thus, when the build directory
> was removed or you tar'ed DESTDIR, git-add was just a regular file and
> all the other builtins were hardlinked to it.

Ah.

But you did not say if you like/tested the patch or not.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile
  2009-05-11 19:08     ` Johannes Schindelin
@ 2009-05-11 20:05       ` Cedric Staniewski
  0 siblings, 0 replies; 6+ messages in thread
From: Cedric Staniewski @ 2009-05-11 20:05 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

Johannes Schindelin wrote:
> But you did not say if you like/tested the patch or not.

Oh, sorry. Of course, it works as intended and I'm fine with applying it.

Thanks for your work.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-11 20:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-11 10:41 Cross-directory hard links Cedric Staniewski
2009-05-11 11:02 ` [PATCH] Add NO_CROSS_DIRECTORY_HARDLINKS support to the Makefile Johannes Schindelin
2009-05-11 16:29   ` Cedric Staniewski
2009-05-11 19:08     ` Johannes Schindelin
2009-05-11 20:05       ` Cedric Staniewski
2009-05-11 16:40 ` Cross-directory hard links Tony Finch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).