linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: Mauricio Silveira <msilveira@linuxbr.com>
Cc: terry white <twhite@aniota.com>,
	linux-admin <linux-admin@vger.kernel.org>
Subject: Re: Compressed Tar : stop on first occurrence
Date: Fri, 20 Oct 2006 22:58:53 +0100	[thread overview]
Message-ID: <17721.18077.490010.833989@cerise.gclements.plus.com> (raw)
In-Reply-To: <453915EB.6090008@linuxbr.com>


Mauricio Silveira wrote:

> terry white wrote:
> > ... ciao:
> >
> > : on "10-20-2006" "Mauricio Silveira" writ:
> > : I'm wondering if there's any way to get tar to stop immediately after
> > : the extraction of a file on compressed tar files. eg: I pack a big tgz
> >
> >     'man tar' offers:
> >
> >        -T, --files-from F
> >               get names to extract or create from file F
> >
> >
> > : when I run "tar xf file.tgz --occurrence index.txt"
> >
> >     HOWEVER , i'm using a gnu flavour 'tar', which does "not" list
> > '--occurrence' as an option, so, the suggestion above may not apply ..
> I know 1.13 doesn't have this option (at least on command line help).
> 
> I did some research on the source code for tar 1.15.1 and found a place 
> to insert a simple exit() when using "--occurrence filename" to force 
> tar to quit on a "match".
> 
> I think this is the way tar should behave... compressed or non 
> compressed files, tar actions behavior should be the same.

The issue isn't compressed vs non-compressed. tar doesn't read
compressed files, ever; if you use -z, -j, or --use-compress-program,
tar spawns a child process to perform [de]compression. tar itself only
ever reads or writes uncompressed archives.

The issue is reading an archive from a file vs reading it from a pipe
or socket. In the latter case, it *intentionally* reads the entire
stream to avoid causing abnormal termination in the process which is
producing the data (e.g. gzip, in the case of -x).

> I think I should send tar this issue as a bug... as far as tar waits for 
> its child "compress program" pipe to end.

If you read any of what I wrote, you will realise that it isn't a bug,
it's quite intentional behaviour.

> --- list.c.org	2006-10-20 15:09:17.000000000 -0200
> +++ list.c	2006-10-20 15:07:51.000000000 -0200
> @@ -199,6 +199,7 @@
>      }
>    while (!all_names_found (&current_stat_info));
>  
> +  exit(EXIT_SUCCESS);
>    close_archive ();
>    names_notfound ();		/* print names not found */
>  }

This "fix" is wrong on so many levels. If you don't want to drain the
pipe, then don't drain the pipe, as I explained last time. There's no
reason to bypass the rest of the termination process, all of which is
there for one reason or another.

-- 
Glynn Clements <glynn@gclements.plus.com>

  reply	other threads:[~2006-10-20 21:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-15 16:23 possible SMTP attack: command=HELO/EHLO, count=3 (fwd) terry white
2006-10-15 18:40 ` Adrian C.
2006-10-16  7:48 ` Glynn Clements
2006-10-16 14:27   ` terry white
2006-10-20 12:44 ` Compressed Tar : stop on first occurrence Mauricio Silveira
2006-10-20 15:10   ` Hendrik Visage
2006-10-20 16:37   ` terry white
2006-10-20 18:31     ` Mauricio Silveira
2006-10-20 21:58       ` Glynn Clements [this message]
2006-10-20 18:40     ` Glynn Clements

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=17721.18077.490010.833989@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=linux-admin@vger.kernel.org \
    --cc=msilveira@linuxbr.com \
    --cc=twhite@aniota.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).