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

Re: how do I extract a 2.6 gigabyte .tar.gz file ?



Darxus <darxus@Op.Net> writes:
| On 29 Oct 1998, Gary L. Hennigan wrote:
| 
| > A fellow user, via personal email, suggested you might try the Unix
| > "head" utility. Something like:
| > 
| > head --bytes 1900m |gzip -d -c|tar tf -
| 
| Unfortunately that has the same result -- nothing.
| ________________________________________________________________________

Okay, I wrote this code based on a suggestion from the Kernel mailing
list. Give it a shot and see what happens. You run it just like you
would using cat, e.g.,

readbytes file.tgz|gunzip -c|tar tf -

The suggestion was that perhaps "open()" wasn't susceptible to the
same problem as fopen(), which all the GNU utilities use and is in
libc.

I tried it on a small gzip'd tar file and it worked. Of course
I can't offer any guarantees. It looks fine to me but I can't/won't
accept responsibility if it does anything horrible like wipes out your 
file! :)

I posted it to the list so that others can look at it and make sure I
didn't miss something.

If you want a binary compiled on a Debian 2.0 system let me know and
I'll mail you one.

Gary
-------------------------Begin cut after this-----------------------
#include <stdio.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#define BUFF_SIZE 1024

/*
 * This program uses the "open()" system call to read bytes from a file
 * and output them to stdout.
 */
int main(int argc, char **argv)
{

  ssize_t i1, bytes_read;
  int file_d;
  char inp_buff[BUFF_SIZE];

  /* Check for the file name on the command line */
  if(argc != 2)
  {
    fprintf(stderr, "Usage:\n\treadbytes <filename>\n");
    return 1;
  }

  file_d = open(argv[1], O_RDONLY);
  if(file_d == -1)
  {
    fprintf(stderr, "ERROR: Could not open file \"%s\"!\n", argv[1]);
    return 2;
  }

  while((bytes_read=read(file_d, inp_buff, BUFF_SIZE)) > 0)
  {
    for(i1=0; i1 < bytes_read; i1++)
      fprintf(stdout, "%c", inp_buff[i1]);
  }

  close(file_d);

  return 0;
}


Reply to: