help-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-tar] Re: Can't extract - get "Archive contains obsolescent bas


From: Alexis Huxley
Subject: Re: [Help-tar] Re: Can't extract - get "Archive contains obsolescent base-64 headers"
Date: Sat, 5 Feb 2005 15:41:15 +0100
User-agent: Mutt/1.4.2i

> > I'll try playing with my perl extraction script some more, but I'll
> > still confused about how I get the size of the later file.
> 
> Normally, sizes are expressed in octal text.  The tar.h file of the
> tar source code will tell you where they are.

What I did in the end was wildly assume that all blocks which did not
contain the text 'ustar' were data blocks and I wrote  consecutive
sequences out to different files, with the  'size rounded up to nearest
block' excess included.

>From there I was able to verify that the content of all files itself was 
corrupt.

Oh well, I'll stop there. Thank you very much everyone for your
assistance!

Alexis

PS In case its any use to googlers, here's the script I used:

--- start ---
#!/usr/bin/perl

$blocksize = 512;
$tarhdrfmt = "A100 a8 a8 a8 a12 a12 a8 a1 a100 a6";
$fileidx = 0;

#  while poss to gets blocks ...
while ((sysread STDIN,$block,$blocksize) != 0) {

    #  ... chop up header 
    ($name, $mode, $uid, $gid, $size, $mtime, $chksum, $type, $linkname, 
$magic) = unpack($tarhdrfmt, $block);

    #  strip trailing null bytes
    $name =~ s/\0*$//;
    $mode =~ s/\0*$//;
    $uid =~ s/\0*$//;
    $gid =~ s/\0*$//;
    $size =~ s/\0*$//;
    $mtime =~ s/\0*$//;
    $chksum =~ s/\0*$//;
    $linkname =~ s/\0*$//;
    $magic =~ s/\0*$//;

    #  switch to numeric - superfluous?
    $mode = oct($mode);
    $uid = oct($uid);
    $gid = oct($gid);
    $size = oct($size);
    $mtime = oct($mtime);
    $chksum = oct($chksum);

    #  if it looks like a header close any open file and open a new one in 
preparation
    #  for writing the data blocks which will follow it.
    if ($magic =~ /ustar/ && $type == 0) {
        close HANDLE if ($fileidx);
        $fileidx++;
        printf "opening file$fileidx ...\n";
        open(HANDLE, ">file$fileidx") || die;

    #  if it doesn't look like a header, then it must (wild assumption) be a 
data 
    #  block so write it out to the already opened file.
    } else {
        syswrite HANDLE,$block,$blocksize;
    }
}

#  close the last opened file.
close HANDLE;
--- end ---




reply via email to

[Prev in Thread] Current Thread [Next in Thread]