From 15dfe78baaefd19ac569500360e645c1b595ece6 Mon Sep 17 00:00:00 2001 From: kientzle Date: Wed, 22 Dec 2004 02:35:37 +0000 Subject: [PATCH] Don't truncate major/minor numbers written to the legacy ustar fields. Later, we're going to permit numeric extensions for these fields, so we can support large values here. In particular, this allows GNU tar to correctly extract such entries even though it doesn't support the pax extended attributes. Note: r1.18 and r1.17.2.1 of this file allowed similar treatment of the uid/gid fields. Thanks to: Ben Mesander --- lib/libarchive/archive_write_set_format_pax.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c index 8593eb7f2dea..94e608a07bb1 100644 --- a/lib/libarchive/archive_write_set_format_pax.c +++ b/lib/libarchive/archive_write_set_format_pax.c @@ -466,7 +466,17 @@ archive_write_pax_header(struct archive *a, if (rdevmajor >= (1 << 18)) { add_pax_attr_int(&(pax->pax_header), "SCHILY.devmajor", rdevmajor); - archive_entry_set_rdevmajor(entry_main, (1 << 18) - 1); + /* + * Non-strict formatting below means we don't + * have to truncate here. Not truncating improves + * the chance that some more modern tar archivers + * (such as GNU tar 1.13) can restore the full + * value even if they don't understand the pax + * extended attributes. See my rant below about + * file size fields for additional details. + */ + /* archive_entry_set_rdevmajor(entry_main, + rdevmajor & ((1 << 18) - 1)); */ need_extension = 1; } @@ -477,7 +487,9 @@ archive_write_pax_header(struct archive *a, if (rdevminor >= (1 << 18)) { add_pax_attr_int(&(pax->pax_header), "SCHILY.devminor", rdevminor); - archive_entry_set_rdevminor(entry_main, (1 << 18) - 1); + /* Truncation is not necessary here, either. */ + /* archive_entry_set_rdevminor(entry_main, + rdevminor & ((1 << 18) - 1)); */ need_extension = 1; } } @@ -513,7 +525,7 @@ archive_write_pax_header(struct archive *a, * The following items are handled differently in "pax * restricted" format. In particular, in "pax restricted" * format they won't be added unless need_extension is - * already set (we're already generated an extended header, so + * already set (we're already generating an extended header, so * may as well include these). */ if (a->archive_format != ARCHIVE_FORMAT_TAR_PAX_RESTRICTED ||