From dawes@landfill.physics.usyd.edu.au  Sun Nov 10 19:41:39 1996
Received: from landfill.physics.usyd.edu.au (landfill.physics.usyd.edu.au [129.78.129.18])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id TAA09046
          for <FreeBSD-gnats-submit@freebsd.org>; Sun, 10 Nov 1996 19:41:33 -0800 (PST)
Received: (from dawes@localhost) by landfill.physics.usyd.edu.au (8.8.2/8.7.3) id OAA15671; Mon, 11 Nov 1996 14:41:23 +1100 (EST)
Message-Id: <199611110341.OAA15671@landfill.physics.usyd.edu.au>
Date: Mon, 11 Nov 1996 14:41:23 +1100 (EST)
From: David Dawes <dawes@landfill.physics.usyd.edu.au>
Reply-To: dawes@physics.usyd.edu.au
To: FreeBSD-gnats-submit@freebsd.org
Cc: dawes@physics.usyd.edu.au
Subject: Gnu tar has problems with hard links to files with long names
X-Send-Pr-Version: 3.2

>Number:         1992
>Category:       gnu
>Synopsis:       Gnu tar has problems with hard links to files with long names
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 10 19:50:02 PST 1996
>Closed-Date:    Tue Nov 12 10:14:44 PST 1996
>Last-Modified:  Tue Nov 12 10:16:22 PST 1996
>Originator:     David Dawes
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
University of Sydney, Australia
>Environment:

>Description:

Gnu tar has problems creating an archive which contains a file with a hard
link to another file which has a long (>=100 char) name.  When listing such
an archive, the name of the link is truncated to 99 characters, and when
extracting such an archive, an error is reported because it is trying to
create a hard link to a file which doesn't exist.

>How-To-Repeat:

    mkdir -p 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789
    mkdir -p 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/xx
    echo stuff > 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/file
    ln 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/file 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/xx/link
    tar cf test.tar 123456789

Then listing with 'tar vtf test.tar' gives:

-rw-r--r-- dawes/theory      0 Nov 11 14:35 1996 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/file link to 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789

And attempting to extract gives:

tar: Could not link 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/file to 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789 : No such file or directory

>Fix:
	
The following patch appears to fix the problem, which is seems to
be a long-standing problem with gnu tar.  I'm planning to send this
patch to the maintainer of gnu tar.

Index: create.c
===================================================================
RCS file: /home/cvs/src/gnu/usr.bin/tar/create.c,v
retrieving revision 1.3
diff -c -r1.3 create.c
*** create.c	1995/06/26 06:24:37	1.3
--- create.c	1996/11/11 03:22:52
***************
*** 313,319 ****
  		    }
  		  link_name++;
  		}
! 	      if (link_name - lp->name >= NAMSIZ)
  		write_long (link_name, LF_LONGLINK);
  	      current_link_name = link_name;
  
--- 313,319 ----
  		    }
  		  link_name++;
  		}
! 	      if (strlen(link_name) >= NAMSIZ)
  		write_long (link_name, LF_LONGLINK);
  	      current_link_name = link_name;
  
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jkh 
State-Changed-When: Tue Nov 12 10:14:44 PST 1996 
State-Changed-Why:  
Submitted fix applied. 
>Unformatted:
