9front - general discussion about 9front
 help / color / mirror / Atom feed
From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: bug: tar doesnt understand pax extended headers
Date: Fri, 14 Sep 2018 19:56:52 -0700	[thread overview]
Message-ID: <CAH_zEu7dOEov3Zi_DyJuo2rYPC7Wrt-8u5-xOteBuLB-UKKXAg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1183 bytes --]

tar(1) doesn't understand pax extended headers. attached is a patch
which will simply ignore pax headers.

see http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html
for a description of the headers and their format.

in the above documentation the type is referred to by 'typeflag', and
in tar.c, linkflag. pax extended headers have two types, 'x' and 'g'.

the main thing that these seem to be useful for are file names which
are longer than whats normally representable.

right now, tar(1) will treat these pax extended headers as normal
"files" and extract the headers to disk, cluttering the fs.

for now we could simply ignore them (easy), but it would be ideal to
read them to find the long path names. the only trouble with this is
that one needs to parse all of the pax 'size key=value\n' attributes
in the pax extended header, finding the 'path' key and using its value
as the new path. there's already some provision for this in tar.c's
"getname" function. there's also no fixed size for these pax
attributes, so filenames can (in theory) be of unlimited length.

if anyone wants to pick this up, the "archive/tar" package in go seems
like a decent reference.

[-- Attachment #2: tar.c.patch --]
[-- Type: text/x-patch, Size: 573 bytes --]

diff --git a/sys/src/cmd/tar.c b/sys/src/cmd/tar.c
--- a/sys/src/cmd/tar.c
+++ b/sys/src/cmd/tar.c
@@ -78,6 +78,8 @@ enum {
 
 	LF_LONGNAME =	'L',		/* GNU extenstion */
 	LF_LONGLINK = 	'K',
+	LF_PAXX		=	'x',
+	LF_PAXG		=	'g',
 };
 
 #define islink(lf)	(isreallink(lf) || issymlink(lf))
@@ -1061,6 +1063,9 @@ openfname(Hdr *hp, char *fname, int dir,
 	case LF_FIFO:
 		fprint(2, "%s: can't make fifo %s\n", argv0, fname);
 		break;
+	case LF_PAXX:
+	case LF_PAXG:
+		break;
 	default:
 		if (!keepexisting || access(fname, AEXIST) < 0) {
 			int rw = (dir? OREAD: OWRITE);

             reply	other threads:[~2018-09-15  2:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-15  2:56 Nick Owens [this message]
2018-09-25  3:27 Jordan Niethe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH_zEu7dOEov3Zi_DyJuo2rYPC7Wrt-8u5-xOteBuLB-UKKXAg@mail.gmail.com \
    --to=mischief@offblast.org \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).