From owner-freebsd-current@FreeBSD.ORG Sat Sep 4 21:22:29 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 73F9216A4CE for ; Sat, 4 Sep 2004 21:22:29 +0000 (GMT) Received: from kientzle.com (h-66-166-149-50.snvacaid.covad.net [66.166.149.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 03DC443D39 for ; Sat, 4 Sep 2004 21:22:29 +0000 (GMT) (envelope-from kientzle@freebsd.org) Received: from freebsd.org (p54.kientzle.com [66.166.149.54]) by kientzle.com (8.12.9/8.12.9) with ESMTP id i84LMP90083418; Sat, 4 Sep 2004 14:22:25 -0700 (PDT) (envelope-from kientzle@freebsd.org) Message-ID: <413A3211.7040506@freebsd.org> Date: Sat, 04 Sep 2004 14:22:25 -0700 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.4) Gecko/20031006 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Will Froning References: <20040903165214.W8095@angui.sh> <41392082.3010204@freebsd.org> In-Reply-To: <41392082.3010204@freebsd.org> Content-Type: multipart/mixed; boundary="------------030102020109050001060900" cc: freebsd-current@freebsd.org Subject: Re: bsdtar breakage on 5.3-BETA2 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2004 21:22:29 -0000 This is a multi-part message in MIME format. --------------030102020109050001060900 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Will Froning wrote: > > On a FBSD4.10 box I have created a tar file of a users home directory > and then copied it over to a 5.3-BETA2 box (MD5 checksums match). > > [ ... file with long name gets reported as a dir instead of regular file ....] > Good catch! The code for handling certain very old tar archives was getting confused by the long filename extensions. The attached patch fixes it for me. If you have a chance, apply it to src/lib/libarchive and then rebuild both libarchive and src/usr.bin/tar and let me know if this fixes it for you as well. Tim --------------030102020109050001060900 Content-Type: text/plain; name="libarchive-archive_read_support_format_tar.c.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="libarchive-archive_read_support_format_tar.c.diff" --- libarchive-current/archive_read_support_format_tar.c Wed Aug 25 20:25:58 2004 +++ libarchive/archive_read_support_format_tar.c Sat Sep 4 13:59:40 2004 @@ -351,12 +351,33 @@ { struct stat st; struct tar *tar; + const char *p; + int r; + size_t l; memset(&st, 0, sizeof(st)); tar = *(a->pformat_data); tar->entry_offset = 0; - return (tar_read_header(a, tar, entry, &st)); + r = tar_read_header(a, tar, entry, &st); + + if (r == ARCHIVE_OK) { + /* + * "Regular" entry with trailing '/' is really + * directory: This is needed for certain old tar + * variants and even for some broken newer ones. + */ + p = archive_entry_pathname(entry); + l = strlen(p); + if (S_ISREG(st.st_mode) && p[l-1] == '/') { + st.st_mode &= ~S_IFMT; + st.st_mode |= S_IFDIR; + } + + /* Copy the final stat data into the entry. */ + archive_entry_copy_stat(entry, &st); + } + return (r); } static int @@ -421,8 +442,6 @@ ssize_t bytes; int err; const void *h; - const char *p; - size_t l; const struct archive_entry_header_ustar *header; /* Read 512-byte header record */ @@ -513,17 +532,9 @@ a->archive_format_name = "tar (non-POSIX)"; err = header_old_tar(a, tar, entry, st, h); } - - /* "Regular" entry with trailing '/' is really directory. */ - p = archive_entry_pathname(entry); - l = strlen(p); - if (S_ISREG(st->st_mode) && p[l-1] == '/') { - st->st_mode &= ~S_IFMT; - st->st_mode |= S_IFDIR; - } } - archive_entry_copy_stat(entry, st); --tar->header_recursion_depth; + return (err); } --------------030102020109050001060900--