Subject: Re: do we really have to "break" 'tar -o' *again*?!?!
To: NetBSD-current Discussion List <current-users@netbsd.org>
From: Greg A. Woods <woods@most.weird.com>
List: current-users
Date: 02/04/1999 15:27:02
[ On Wednesday, February 3, 1999 at 10:38:17 (-0800), The Grey Wolf wrote: ]
> Subject: Re: do we really have to "break" 'tar -o' *again*?!?!
>
> Um, exCUSE me.
> 
> NetBSD's tar may be / have been GNU tar, but according to the 4.2 BSD
> UNIX User's Manual Reference Guide (URM):
> 
> "The following characters may be used in addition to the letter which 
>  selects the function desired.
> 
> "o      On output, tar normally places information specifying owner and
>         modes of directories in the archive.  Former versions of tar,
>         when encountering this information will give error message
>         of the form
>                 <name>/: cannot create
>         This modifier will suppress the directory information."
> 
> In other words, it looks as though this is a holdover from Berkeley UNIX'
> attempt to deal with old (V7/V6) archives.  So if you're going to use
> a Binford 9000 Turbo Roaster on anyone, flame the CSRG for this.  They
> had their reasons, and they were quite good, so I don't really advise
> this either :-).

Indeed, CSRG is the original culprit on this one, *BUT* the industry
standards bodies, in their complete schizophrenia, have decided that 
the deprecated 'tar' interface doesn't need to generate V7 archives any
more (they suggest using the 'pax' interface to do that, silly them),
and instead they've settled no the original PAX definition of tar's '-o'.

Unfortunately I now see that the original 4.4BSD pax-as-tar '-o' doesn't
do what the original PAX did either:

       -o        Causes extracted files to take on the  user  and
                 group identifier of the user running the program
                 rather than those on the archive.  This modifier
                 is only valid with the -x option.

(which of course matches The Single UNIX Specification Version 2)

I wondered only too briefly what "write_opt=nodir" really meant the
first time I scanned through the source....

And some folks blame vendors for introducing "proprietary" changes to
attempt to lock in their users!  ;-)

After all of this I certainly wouldn't object if pax-as-tar's '-o'
operated as per BSD when creating an archive (thus providing a superset
of features beyond SUSv2), but I think in the interests of forward
progress and standards compliance NetBSD should not deviate from either
the original 4.4BSD pax-as-tar, nor from the standards where '-o' is
specified for extraction.

As it turns out the original code, prior to the change that started this
thread, was already doing exactly as I propose it do again.  The change
in fact made '-o' have a null effect (and thus actually makes it
impossible to create V7 compatible archives with pax-as-tar).  Note the
code later in the function, after processing options, which says:

	/*
	 * if we are writing (ARCHIVE) specify tar, otherwise run like pax
	 */
	if (act == ARCHIVE)
		frmt = &(fsub[F_TAR]);

How about the following change, which clarifies the comments in hopes
people won't make this kind of mistake again:

Index: options.c
===================================================================
RCS file: /cvs/NetBSD/src/bin/pax/options.c,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 options.c
*** options.c	1998/11/16 19:19:44	1.1.1.4
--- options.c	1999/02/04 20:21:03
***************
*** 132,138 ****
  #define F_CPIO		1	/* old octal character cpio format */
  #define F_SV4CPIO	2	/* SVR4 hex cpio format */
  #define F_SV4CRC	3	/* SVR4 hex with crc cpio format */
! #define F_TAR		4	/* format when called as tar */
  #define F_USTAR		5	/* ustar format */
  #define DEFLT		F_USTAR	/* default write format from list above */
  
--- 132,138 ----
  #define F_CPIO		1	/* old octal character cpio format */
  #define F_SV4CPIO	2	/* SVR4 hex cpio format */
  #define F_SV4CRC	3	/* SVR4 hex with crc cpio format */
! #define F_TAR		4	/* old tar format (used when called as tar) */
  #define F_USTAR		5	/* ustar format */
  #define DEFLT		F_USTAR	/* default write format from list above */
  
***************
*** 670,675 ****
--- 670,679 ----
  			pmtime = 0;
  			break;
  		case 'o':
+ 			/*
+ 			 * create really ancient format tar archives,
+ 			 * i.e. those without directory headers....
+ 			 */
  			if (opt_add("write_opt=nodir") < 0)
  				tar_usage();
  			break;

It would be *nice* if the 4.4BSD pax did what the "real" PAX does too:

***************
*** 670,675 ****
--- 670,679 ----
  			pmtime = 0;
  			break;
  		case 'o':
+ 			/*
+ 			 * create really ancient format tar archives,
+ 			 * i.e. those without directory headers....
+ 			 */
  			if (opt_add("write_opt=nodir") < 0)
  				tar_usage();
+ 			pids = 0;
  			break;

-- 
							Greg A. Woods

+1 416 218-0098      VE3TCP      <gwoods@acm.org>      <robohack!woods>
Planix, Inc. <woods@planix.com>; Secrets of the Weird <woods@weird.com>