Re: cpio/pax using libarchive? (was Re: Replace /rescue/vi with mined(1) from DragonFlyBSD)

From: Tim Kientzle <kientzle_at_freebsd.org>
Date: Mon, 20 Jun 2005 19:24:43 -0700
Tim Robbins wrote:
> 
> This is a bit off topic, but is there a good reason (other than lack of
> time) that cpio and pax could not be rewritten to use libarchive?

None at all.  I've focused on tar primarily because I use it more
than the others myself, and because I keep dreaming I'll find time
to get back to work on libpkg.  <sigh>

If anyone would like to tackle this, I have one concrete suggestion:
start with passthrough (copy) mode.  If I understand it correctly,
it can be implemented quite simply by forking:

   /* process args, set up read_arg_struct and write_arg_struct */

   switch (mode) {
   case PASSTHROUGH:
     {
       int fd[2];
       pipe(fd);
       if (fork())
         cpio_read(fd[0], read_arg_struct);
       else
         cpio_write(fd[1], write_arg_struct);
       break;
     }
   case READ:
     {
       cpio_read(...);
       break;
     }
   case WRITE:
     {
       cpio_write(...);
       break;
     }
   }

A lot of the detailed code can doubtless be cribbed from tar.  Once 
you've figured out 'cpio', then basic 'pax' should be pretty simple.
Hardest part of 'pax' is working on the regex substitutions and
extended pax attribute overrides (which will require augmenting
the libarchive API in tricky ways).

Tim
Received on Tue Jun 21 2005 - 00:25:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:37 UTC