Home | History | Annotate | Line # | Download | only in pax
options.c revision 1.13
      1  1.13   mycroft /*	$NetBSD: options.c,v 1.13 1998/07/28 11:41:50 mycroft Exp $	*/
      2   1.5       cgd 
      3   1.1       jtc /*-
      4   1.1       jtc  * Copyright (c) 1992 Keith Muller.
      5   1.1       jtc  * Copyright (c) 1992, 1993
      6   1.1       jtc  *	The Regents of the University of California.  All rights reserved.
      7   1.1       jtc  *
      8   1.1       jtc  * This code is derived from software contributed to Berkeley by
      9   1.1       jtc  * Keith Muller of the University of California, San Diego.
     10   1.1       jtc  *
     11   1.1       jtc  * Redistribution and use in source and binary forms, with or without
     12   1.1       jtc  * modification, are permitted provided that the following conditions
     13   1.1       jtc  * are met:
     14   1.1       jtc  * 1. Redistributions of source code must retain the above copyright
     15   1.1       jtc  *    notice, this list of conditions and the following disclaimer.
     16   1.1       jtc  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.1       jtc  *    notice, this list of conditions and the following disclaimer in the
     18   1.1       jtc  *    documentation and/or other materials provided with the distribution.
     19   1.1       jtc  * 3. All advertising materials mentioning features or use of this software
     20   1.1       jtc  *    must display the following acknowledgement:
     21   1.1       jtc  *	This product includes software developed by the University of
     22   1.1       jtc  *	California, Berkeley and its contributors.
     23   1.1       jtc  * 4. Neither the name of the University nor the names of its contributors
     24   1.1       jtc  *    may be used to endorse or promote products derived from this software
     25   1.1       jtc  *    without specific prior written permission.
     26   1.1       jtc  *
     27   1.1       jtc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28   1.1       jtc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29   1.1       jtc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30   1.1       jtc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31   1.1       jtc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32   1.1       jtc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33   1.1       jtc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34   1.1       jtc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35   1.1       jtc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36   1.1       jtc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37   1.1       jtc  * SUCH DAMAGE.
     38   1.1       jtc  */
     39   1.1       jtc 
     40   1.8  christos #include <sys/cdefs.h>
     41   1.1       jtc #ifndef lint
     42   1.5       cgd #if 0
     43   1.5       cgd static char sccsid[] = "@(#)options.c	8.2 (Berkeley) 4/18/94";
     44   1.5       cgd #else
     45  1.13   mycroft __RCSID("$NetBSD: options.c,v 1.13 1998/07/28 11:41:50 mycroft Exp $");
     46   1.5       cgd #endif
     47   1.1       jtc #endif /* not lint */
     48   1.1       jtc 
     49   1.1       jtc #include <sys/types.h>
     50   1.1       jtc #include <sys/time.h>
     51   1.1       jtc #include <sys/stat.h>
     52   1.1       jtc #include <sys/mtio.h>
     53   1.1       jtc #include <sys/param.h>
     54   1.1       jtc #include <stdio.h>
     55   1.1       jtc #include <ctype.h>
     56   1.1       jtc #include <string.h>
     57   1.1       jtc #include <unistd.h>
     58   1.1       jtc #include <stdlib.h>
     59   1.1       jtc #include <limits.h>
     60   1.1       jtc #include "pax.h"
     61   1.1       jtc #include "options.h"
     62   1.1       jtc #include "cpio.h"
     63   1.1       jtc #include "tar.h"
     64   1.1       jtc #include "extern.h"
     65   1.1       jtc 
     66   1.1       jtc /*
     67   1.1       jtc  * Routines which handle command line options
     68   1.1       jtc  */
     69   1.1       jtc 
     70  1.10       mrg int cpio_mode;			/* set if we are in cpio mode */
     71  1.10       mrg char *chdir_dir;		/* directory to chdir to before operating */
     72  1.10       mrg 
     73  1.10       mrg static char *flgch = FLGCH;	/* list of all possible flags (pax) */
     74   1.1       jtc static OPLIST *ophead = NULL;	/* head for format specific options -x */
     75   1.1       jtc static OPLIST *optail = NULL;	/* option tail */
     76   1.1       jtc 
     77   1.1       jtc static int no_op __P((void));
     78   1.1       jtc static void printflg __P((unsigned int));
     79   1.1       jtc static int c_frmt __P((const void *, const void *));
     80   1.1       jtc static off_t str_offt __P((char *));
     81   1.7       tls static void pax_options __P((int, char **));
     82   1.1       jtc static void pax_usage __P((void));
     83   1.7       tls static void tar_options __P((int, char **));
     84   1.1       jtc static void tar_usage __P((void));
     85   1.7       tls static void cpio_options __P((int, char **));
     86   1.1       jtc static void cpio_usage __P((void));
     87   1.1       jtc 
     88   1.6       mrg #define GZIP_CMD	"gzip"		/* command to run as gzip */
     89   1.6       mrg #define COMPRESS_CMD	"compress"	/* command to run as compress */
     90   1.6       mrg 
     91   1.1       jtc /*
     92   1.1       jtc  *	Format specific routine table - MUST BE IN SORTED ORDER BY NAME
     93   1.1       jtc  *	(see pax.h for description of each function)
     94   1.1       jtc  *
     95   1.1       jtc  * 	name, blksz, hdsz, udev, hlk, blkagn, inhead, id, st_read,
     96   1.1       jtc  *	read, end_read, st_write, write, end_write, trail,
     97   1.1       jtc  *	rd_data, wr_data, options
     98   1.1       jtc  */
     99   1.1       jtc 
    100   1.1       jtc FSUB fsub[] = {
    101   1.1       jtc /* 0: OLD BINARY CPIO */
    102   1.8  christos 	{ "bcpio", 5120, sizeof(HD_BCPIO), 1, 0, 0, 1, bcpio_id, cpio_strd,
    103   1.8  christos 	bcpio_rd, bcpio_endrd, cpio_stwr, bcpio_wr, cpio_endwr, NULL,
    104   1.8  christos 	cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt },
    105   1.1       jtc 
    106   1.1       jtc /* 1: OLD OCTAL CHARACTER CPIO */
    107   1.8  christos 	{ "cpio", 5120, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd,
    108   1.8  christos 	cpio_rd, cpio_endrd, cpio_stwr, cpio_wr, cpio_endwr, NULL,
    109   1.8  christos 	cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt },
    110   1.1       jtc 
    111   1.1       jtc /* 2: SVR4 HEX CPIO */
    112   1.8  christos 	{ "sv4cpio", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, vcpio_id, cpio_strd,
    113   1.8  christos 	vcpio_rd, vcpio_endrd, cpio_stwr, vcpio_wr, cpio_endwr, NULL,
    114   1.8  christos 	cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt },
    115   1.1       jtc 
    116   1.1       jtc /* 3: SVR4 HEX CPIO WITH CRC */
    117   1.8  christos 	{ "sv4crc", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd,
    118   1.8  christos 	vcpio_rd, vcpio_endrd, crc_stwr, vcpio_wr, cpio_endwr, NULL,
    119   1.8  christos 	cpio_subtrail, rd_wrfile, wr_rdfile, bad_opt },
    120   1.1       jtc 
    121   1.1       jtc /* 4: OLD TAR */
    122   1.8  christos 	{ "tar", 10240, BLKMULT, 0, 1, BLKMULT, 0, tar_id, no_op,
    123   1.1       jtc 	tar_rd, tar_endrd, no_op, tar_wr, tar_endwr, tar_trail,
    124   1.8  christos 	NULL, rd_wrfile, wr_rdfile, tar_opt },
    125   1.1       jtc 
    126   1.1       jtc /* 5: POSIX USTAR */
    127   1.8  christos 	{ "ustar", 10240, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, ustar_strd,
    128   1.1       jtc 	ustar_rd, tar_endrd, ustar_stwr, ustar_wr, tar_endwr, tar_trail,
    129   1.8  christos 	NULL, rd_wrfile, wr_rdfile, bad_opt }
    130   1.1       jtc };
    131  1.10       mrg #define F_BCPIO		0	/* old binary cpio format */
    132  1.10       mrg #define F_CPIO		1	/* old octal character cpio format */
    133  1.10       mrg #define F_SV4CPIO	2	/* SVR4 hex cpio format */
    134  1.10       mrg #define F_SV4CRC	3	/* SVR4 hex with crc cpio format */
    135  1.10       mrg #define F_TAR		4	/* format when called as tar */
    136  1.10       mrg #define F_USTAR		5	/* ustar format */
    137  1.10       mrg #define DEFLT		F_USTAR	/* default write format from list above */
    138   1.1       jtc 
    139   1.1       jtc /*
    140   1.1       jtc  * ford is the archive search order used by get_arc() to determine what kind
    141   1.1       jtc  * of archive we are dealing with. This helps to properly id  archive formats
    142   1.1       jtc  * some formats may be subsets of others....
    143   1.1       jtc  */
    144  1.10       mrg int ford[] = {F_USTAR, F_TAR, F_SV4CRC, F_SV4CPIO, F_CPIO, F_BCPIO, -1};
    145   1.1       jtc 
    146   1.1       jtc /*
    147   1.1       jtc  * options()
    148   1.1       jtc  *	figure out if we are pax, tar or cpio. Call the appropriate options
    149   1.1       jtc  *	parser
    150   1.1       jtc  */
    151   1.1       jtc 
    152   1.1       jtc #if __STDC__
    153   1.1       jtc void
    154   1.7       tls options(int argc, char **argv)
    155   1.1       jtc #else
    156   1.1       jtc void
    157   1.1       jtc options(argc, argv)
    158   1.7       tls 	int argc;
    159   1.7       tls 	char **argv;
    160   1.1       jtc #endif
    161   1.1       jtc {
    162   1.1       jtc 
    163   1.1       jtc 	/*
    164   1.1       jtc 	 * Are we acting like pax, tar or cpio (based on argv[0])
    165   1.1       jtc 	 */
    166   1.1       jtc 	if ((argv0 = strrchr(argv[0], '/')) != NULL)
    167   1.1       jtc 		argv0++;
    168   1.1       jtc 	else
    169   1.1       jtc 		argv0 = argv[0];
    170   1.1       jtc 
    171   1.1       jtc 	if (strcmp(NM_TAR, argv0) == 0)
    172  1.13   mycroft 		tar_options(argc, argv);
    173   1.1       jtc 	else if (strcmp(NM_CPIO, argv0) == 0)
    174  1.13   mycroft 		cpio_options(argc, argv);
    175  1.13   mycroft 	else {
    176  1.13   mycroft 		argv0 = NM_PAX;
    177  1.13   mycroft 		pax_options(argc, argv);
    178  1.13   mycroft 	}
    179   1.1       jtc }
    180   1.1       jtc 
    181   1.1       jtc /*
    182   1.1       jtc  * pax_options()
    183   1.1       jtc  *	look at the user specified flags. set globals as required and check if
    184   1.1       jtc  *	the user specified a legal set of flags. If not, complain and exit
    185   1.1       jtc  */
    186   1.1       jtc 
    187   1.1       jtc #if __STDC__
    188   1.1       jtc static void
    189   1.7       tls pax_options(int argc, char **argv)
    190   1.1       jtc #else
    191   1.1       jtc static void
    192   1.1       jtc pax_options(argc, argv)
    193   1.7       tls 	int argc;
    194   1.7       tls 	char **argv;
    195   1.1       jtc #endif
    196   1.1       jtc {
    197   1.7       tls 	int c;
    198   1.7       tls 	int i;
    199   1.1       jtc 	unsigned int flg = 0;
    200   1.1       jtc 	unsigned int bflg = 0;
    201   1.7       tls 	char *pt;
    202   1.1       jtc         FSUB tmp;
    203   1.1       jtc 	extern char *optarg;
    204   1.1       jtc 	extern int optind;
    205   1.1       jtc 
    206   1.1       jtc 	/*
    207   1.1       jtc 	 * process option flags
    208   1.1       jtc 	 */
    209   1.6       mrg 	while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ"))
    210   1.9     lukem 	    != -1) {
    211   1.1       jtc 		switch (c) {
    212   1.1       jtc 		case 'a':
    213   1.1       jtc 			/*
    214   1.1       jtc 			 * append
    215   1.1       jtc 			 */
    216   1.1       jtc 			flg |= AF;
    217   1.1       jtc 			break;
    218   1.1       jtc 		case 'b':
    219   1.1       jtc 			/*
    220   1.1       jtc 			 * specify blocksize
    221   1.1       jtc 			 */
    222   1.1       jtc 			flg |= BF;
    223   1.1       jtc 			if ((wrblksz = (int)str_offt(optarg)) <= 0) {
    224   1.8  christos 				tty_warn(1, "Invalid block size %s", optarg);
    225   1.1       jtc 				pax_usage();
    226   1.1       jtc 			}
    227   1.1       jtc 			break;
    228   1.1       jtc 		case 'c':
    229   1.1       jtc 			/*
    230   1.1       jtc 			 * inverse match on patterns
    231   1.1       jtc 			 */
    232   1.1       jtc 			cflag = 1;
    233   1.1       jtc 			flg |= CF;
    234   1.1       jtc 			break;
    235   1.1       jtc 		case 'd':
    236   1.1       jtc 			/*
    237   1.1       jtc 			 * match only dir on extract, not the subtree at dir
    238   1.1       jtc 			 */
    239   1.1       jtc 			dflag = 1;
    240   1.1       jtc 			flg |= DF;
    241   1.1       jtc 			break;
    242   1.1       jtc 		case 'f':
    243   1.1       jtc 			/*
    244   1.1       jtc 			 * filename where the archive is stored
    245   1.1       jtc 			 */
    246   1.1       jtc 			arcname = optarg;
    247   1.1       jtc 			flg |= FF;
    248   1.1       jtc 			break;
    249   1.1       jtc 		case 'i':
    250   1.1       jtc 			/*
    251   1.1       jtc 			 * interactive file rename
    252   1.1       jtc 			 */
    253   1.1       jtc 			iflag = 1;
    254   1.1       jtc 			flg |= IF;
    255   1.1       jtc 			break;
    256   1.1       jtc 		case 'k':
    257   1.1       jtc 			/*
    258   1.1       jtc 			 * do not clobber files that exist
    259   1.1       jtc 			 */
    260   1.1       jtc 			kflag = 1;
    261   1.1       jtc 			flg |= KF;
    262   1.1       jtc 			break;
    263   1.1       jtc 		case 'l':
    264   1.1       jtc 			/*
    265   1.1       jtc 			 * try to link src to dest with copy (-rw)
    266   1.1       jtc 			 */
    267   1.1       jtc 			lflag = 1;
    268   1.1       jtc 			flg |= LF;
    269   1.1       jtc 			break;
    270   1.1       jtc 		case 'n':
    271   1.1       jtc 			/*
    272   1.1       jtc 			 * select first match for a pattern only
    273   1.1       jtc 			 */
    274   1.1       jtc 			nflag = 1;
    275   1.1       jtc 			flg |= NF;
    276   1.1       jtc 			break;
    277   1.1       jtc 		case 'o':
    278   1.1       jtc 			/*
    279   1.1       jtc 			 * pass format specific options
    280   1.1       jtc 			 */
    281   1.1       jtc 			flg |= OF;
    282   1.1       jtc 			if (opt_add(optarg) < 0)
    283   1.1       jtc 				pax_usage();
    284   1.1       jtc 			break;
    285   1.1       jtc 		case 'p':
    286   1.1       jtc 			/*
    287   1.1       jtc 			 * specify file characteristic options
    288   1.1       jtc 			 */
    289   1.1       jtc 			for (pt = optarg; *pt != '\0'; ++pt) {
    290   1.1       jtc 				switch(*pt) {
    291   1.1       jtc 				case 'a':
    292   1.1       jtc 					/*
    293   1.1       jtc 					 * do not preserve access time
    294   1.1       jtc 					 */
    295   1.1       jtc 					patime = 0;
    296   1.1       jtc 					break;
    297   1.1       jtc 				case 'e':
    298   1.1       jtc 					/*
    299   1.1       jtc 					 * preserve user id, group id, file
    300   1.1       jtc 					 * mode, access/modification times
    301   1.1       jtc 					 */
    302   1.1       jtc 					pids = 1;
    303   1.1       jtc 					pmode = 1;
    304   1.1       jtc 					patime = 1;
    305   1.1       jtc 					pmtime = 1;
    306   1.1       jtc 					break;
    307   1.1       jtc 				case 'm':
    308   1.1       jtc 					/*
    309   1.1       jtc 					 * do not preserve modification time
    310   1.1       jtc 					 */
    311   1.1       jtc 					pmtime = 0;
    312   1.1       jtc 					break;
    313   1.1       jtc 				case 'o':
    314   1.1       jtc 					/*
    315   1.1       jtc 					 * preserve uid/gid
    316   1.1       jtc 					 */
    317   1.1       jtc 					pids = 1;
    318   1.1       jtc 					break;
    319   1.1       jtc 				case 'p':
    320   1.1       jtc 					/*
    321   1.1       jtc 					 * preserver file mode bits
    322   1.1       jtc 					 */
    323   1.1       jtc 					pmode = 1;
    324   1.1       jtc 					break;
    325   1.1       jtc 				default:
    326   1.8  christos 					tty_warn(1,
    327   1.8  christos 					    "Invalid -p string: %c", *pt);
    328   1.1       jtc 					pax_usage();
    329   1.1       jtc 					break;
    330   1.1       jtc 				}
    331   1.1       jtc 			}
    332   1.1       jtc 			flg |= PF;
    333   1.1       jtc 			break;
    334   1.1       jtc 		case 'r':
    335   1.1       jtc 			/*
    336   1.1       jtc 			 * read the archive
    337   1.1       jtc 			 */
    338   1.1       jtc 			flg |= RF;
    339   1.1       jtc 			break;
    340   1.1       jtc 		case 's':
    341   1.1       jtc 			/*
    342   1.1       jtc 			 * file name substitution name pattern
    343   1.1       jtc 			 */
    344   1.1       jtc 			if (rep_add(optarg) < 0) {
    345   1.1       jtc 				pax_usage();
    346   1.1       jtc 				break;
    347   1.1       jtc 			}
    348   1.1       jtc 			flg |= SF;
    349   1.1       jtc 			break;
    350   1.1       jtc 		case 't':
    351   1.1       jtc 			/*
    352   1.1       jtc 			 * preserve access time on filesystem nodes we read
    353   1.1       jtc 			 */
    354   1.1       jtc 			tflag = 1;
    355   1.1       jtc 			flg |= TF;
    356   1.1       jtc 			break;
    357   1.1       jtc 		case 'u':
    358   1.1       jtc 			/*
    359   1.1       jtc 			 * ignore those older files
    360   1.1       jtc 			 */
    361   1.1       jtc 			uflag = 1;
    362   1.1       jtc 			flg |= UF;
    363   1.1       jtc 			break;
    364   1.1       jtc 		case 'v':
    365   1.1       jtc 			/*
    366   1.1       jtc 			 * verbose operation mode
    367   1.1       jtc 			 */
    368   1.1       jtc 			vflag = 1;
    369   1.1       jtc 			flg |= VF;
    370   1.1       jtc 			break;
    371   1.1       jtc 		case 'w':
    372   1.1       jtc 			/*
    373   1.1       jtc 			 * write an archive
    374   1.1       jtc 			 */
    375   1.1       jtc 			flg |= WF;
    376   1.1       jtc 			break;
    377   1.1       jtc 		case 'x':
    378   1.1       jtc 			/*
    379   1.1       jtc 			 * specify an archive format on write
    380   1.1       jtc 			 */
    381   1.1       jtc 			tmp.name = optarg;
    382   1.8  christos 			frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
    383   1.8  christos 			    sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt);
    384   1.8  christos 			if (frmt != NULL) {
    385   1.1       jtc 				flg |= XF;
    386   1.1       jtc 				break;
    387   1.1       jtc 			}
    388   1.8  christos 			tty_warn(1, "Unknown -x format: %s", optarg);
    389   1.1       jtc 			(void)fputs("pax: Known -x formats are:", stderr);
    390   1.1       jtc 			for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
    391   1.1       jtc 				(void)fprintf(stderr, " %s", fsub[i].name);
    392   1.1       jtc 			(void)fputs("\n\n", stderr);
    393   1.1       jtc 			pax_usage();
    394   1.1       jtc 			break;
    395   1.6       mrg 		case 'z':
    396   1.6       mrg 			/*
    397   1.6       mrg 			 * use gzip.  Non standard option.
    398   1.6       mrg 			 */
    399   1.6       mrg 			zflag = 1;
    400   1.6       mrg 			gzip_program = GZIP_CMD;
    401   1.6       mrg 			break;
    402   1.1       jtc 		case 'B':
    403   1.1       jtc 			/*
    404   1.1       jtc 			 * non-standard option on number of bytes written on a
    405   1.1       jtc 			 * single archive volume.
    406   1.1       jtc 			 */
    407   1.1       jtc 			if ((wrlimit = str_offt(optarg)) <= 0) {
    408   1.8  christos 				tty_warn(1, "Invalid write limit %s", optarg);
    409   1.1       jtc 				pax_usage();
    410   1.1       jtc 			}
    411   1.1       jtc 			if (wrlimit % BLKMULT) {
    412   1.8  christos 				tty_warn(1,
    413   1.8  christos 				    "Write limit is not a %d byte multiple",
    414   1.1       jtc 				    BLKMULT);
    415   1.1       jtc 				pax_usage();
    416   1.1       jtc 			}
    417   1.1       jtc 			flg |= CBF;
    418   1.1       jtc 			break;
    419   1.1       jtc 		case 'D':
    420   1.1       jtc 			/*
    421   1.1       jtc 			 * On extraction check file inode change time before the
    422   1.1       jtc 			 * modification of the file name. Non standard option.
    423   1.1       jtc 			 */
    424   1.1       jtc 			Dflag = 1;
    425   1.1       jtc 			flg |= CDF;
    426   1.1       jtc 			break;
    427   1.1       jtc 		case 'E':
    428   1.1       jtc 			/*
    429   1.1       jtc 			 * non-standard limit on read faults
    430   1.1       jtc 			 * 0 indicates stop after first error, values
    431   1.1       jtc 			 * indicate a limit, "NONE" try forever
    432   1.1       jtc 			 */
    433   1.1       jtc 			flg |= CEF;
    434   1.1       jtc 			if (strcmp(NONE, optarg) == 0)
    435   1.1       jtc 				maxflt = -1;
    436   1.1       jtc 			else if ((maxflt = atoi(optarg)) < 0) {
    437   1.8  christos 				tty_warn(1,
    438   1.8  christos 				    "Error count value must be positive");
    439   1.1       jtc 				pax_usage();
    440   1.1       jtc 			}
    441   1.1       jtc 			break;
    442   1.1       jtc 		case 'G':
    443   1.1       jtc 			/*
    444   1.1       jtc 			 * non-standard option for selecting files within an
    445   1.1       jtc 			 * archive by group (gid or name)
    446   1.1       jtc 			 */
    447   1.1       jtc 			if (grp_add(optarg) < 0) {
    448   1.1       jtc 				pax_usage();
    449   1.1       jtc 				break;
    450   1.1       jtc 			}
    451   1.1       jtc 			flg |= CGF;
    452   1.1       jtc 			break;
    453   1.1       jtc 		case 'H':
    454   1.1       jtc 			/*
    455   1.1       jtc 			 * follow command line symlinks only
    456   1.1       jtc 			 */
    457   1.1       jtc 			Hflag = 1;
    458   1.1       jtc 			flg |= CHF;
    459   1.1       jtc 			break;
    460   1.1       jtc 		case 'L':
    461   1.1       jtc 			/*
    462   1.1       jtc 			 * follow symlinks
    463   1.1       jtc 			 */
    464   1.1       jtc 			Lflag = 1;
    465   1.1       jtc 			flg |= CLF;
    466   1.1       jtc 			break;
    467   1.1       jtc 		case 'P':
    468   1.1       jtc 			/*
    469   1.1       jtc 			 * do NOT follow symlinks (default)
    470   1.1       jtc 			 */
    471   1.1       jtc 			Lflag = 0;
    472   1.1       jtc 			flg |= CPF;
    473   1.1       jtc 			break;
    474   1.1       jtc 		case 'T':
    475   1.1       jtc 			/*
    476   1.1       jtc 			 * non-standard option for selecting files within an
    477   1.1       jtc 			 * archive by modification time range (lower,upper)
    478   1.1       jtc 			 */
    479   1.1       jtc 			if (trng_add(optarg) < 0) {
    480   1.1       jtc 				pax_usage();
    481   1.1       jtc 				break;
    482   1.1       jtc 			}
    483   1.1       jtc 			flg |= CTF;
    484   1.1       jtc 			break;
    485   1.1       jtc 		case 'U':
    486   1.1       jtc 			/*
    487   1.1       jtc 			 * non-standard option for selecting files within an
    488   1.1       jtc 			 * archive by user (uid or name)
    489   1.1       jtc 			 */
    490   1.1       jtc 			if (usr_add(optarg) < 0) {
    491   1.1       jtc 				pax_usage();
    492   1.1       jtc 				break;
    493   1.1       jtc 			}
    494   1.1       jtc 			flg |= CUF;
    495   1.1       jtc 			break;
    496   1.1       jtc 		case 'X':
    497   1.1       jtc 			/*
    498   1.1       jtc 			 * do not pass over mount points in the file system
    499   1.1       jtc 			 */
    500   1.1       jtc 			Xflag = 1;
    501   1.1       jtc 			flg |= CXF;
    502   1.1       jtc 			break;
    503   1.1       jtc 		case 'Y':
    504   1.1       jtc 			/*
    505   1.1       jtc 			 * On extraction check file inode change time after the
    506   1.1       jtc 			 * modification of the file name. Non standard option.
    507   1.1       jtc 			 */
    508   1.1       jtc 			Yflag = 1;
    509   1.1       jtc 			flg |= CYF;
    510   1.1       jtc 			break;
    511   1.1       jtc 		case 'Z':
    512   1.1       jtc 			/*
    513   1.1       jtc 			 * On extraction check modification time after the
    514   1.1       jtc 			 * modification of the file name. Non standard option.
    515   1.1       jtc 			 */
    516   1.1       jtc 			Zflag = 1;
    517   1.1       jtc 			flg |= CZF;
    518   1.1       jtc 			break;
    519   1.1       jtc 		case '?':
    520   1.1       jtc 		default:
    521   1.1       jtc 			pax_usage();
    522   1.1       jtc 			break;
    523   1.1       jtc 		}
    524   1.1       jtc 	}
    525   1.1       jtc 
    526   1.1       jtc 	/*
    527   1.1       jtc 	 * figure out the operation mode of pax read,write,extract,copy,append
    528   1.1       jtc 	 * or list. check that we have not been given a bogus set of flags
    529   1.1       jtc 	 * for the operation mode.
    530   1.1       jtc 	 */
    531   1.1       jtc 	if (ISLIST(flg)) {
    532   1.1       jtc 		act = LIST;
    533   1.1       jtc 		bflg = flg & BDLIST;
    534   1.1       jtc 	} else if (ISEXTRACT(flg)) {
    535   1.1       jtc 		act = EXTRACT;
    536   1.1       jtc 		bflg = flg & BDEXTR;
    537   1.1       jtc 	} else if (ISARCHIVE(flg)) {
    538   1.1       jtc 		act = ARCHIVE;
    539   1.1       jtc 		bflg = flg & BDARCH;
    540   1.1       jtc 	} else if (ISAPPND(flg)) {
    541   1.1       jtc 		act = APPND;
    542   1.1       jtc 		bflg = flg & BDARCH;
    543   1.1       jtc 	} else if (ISCOPY(flg)) {
    544   1.1       jtc 		act = COPY;
    545   1.1       jtc 		bflg = flg & BDCOPY;
    546   1.1       jtc 	} else
    547   1.1       jtc 		pax_usage();
    548   1.1       jtc 	if (bflg) {
    549   1.1       jtc 		printflg(flg);
    550   1.1       jtc 		pax_usage();
    551   1.1       jtc 	}
    552   1.1       jtc 
    553   1.1       jtc 	/*
    554   1.1       jtc 	 * if we are writing (ARCHIVE) we use the default format if the user
    555   1.1       jtc 	 * did not specify a format. when we write during an APPEND, we will
    556   1.1       jtc 	 * adopt the format of the existing archive if none was supplied.
    557   1.1       jtc 	 */
    558   1.1       jtc 	if (!(flg & XF) && (act == ARCHIVE))
    559   1.1       jtc 		frmt = &(fsub[DEFLT]);
    560   1.1       jtc 
    561   1.1       jtc 	/*
    562   1.1       jtc 	 * process the args as they are interpreted by the operation mode
    563   1.1       jtc 	 */
    564   1.1       jtc 	switch (act) {
    565   1.1       jtc 	case LIST:
    566   1.1       jtc 	case EXTRACT:
    567   1.1       jtc 		for (; optind < argc; optind++)
    568   1.1       jtc 			if (pat_add(argv[optind]) < 0)
    569   1.1       jtc 				pax_usage();
    570   1.1       jtc 		break;
    571   1.1       jtc 	case COPY:
    572   1.1       jtc 		if (optind >= argc) {
    573   1.8  christos 			tty_warn(0, "Destination directory was not supplied");
    574   1.1       jtc 			pax_usage();
    575   1.1       jtc 		}
    576   1.1       jtc 		--argc;
    577   1.1       jtc 		dirptr = argv[argc];
    578   1.1       jtc 		/* FALL THROUGH */
    579   1.1       jtc 	case ARCHIVE:
    580   1.1       jtc 	case APPND:
    581   1.1       jtc 		for (; optind < argc; optind++)
    582   1.1       jtc 			if (ftree_add(argv[optind]) < 0)
    583   1.1       jtc 				pax_usage();
    584   1.1       jtc 		/*
    585   1.1       jtc 		 * no read errors allowed on updates/append operation!
    586   1.1       jtc 		 */
    587   1.1       jtc 		maxflt = 0;
    588   1.1       jtc 		break;
    589   1.1       jtc 	}
    590   1.1       jtc }
    591   1.1       jtc 
    592   1.1       jtc 
    593   1.1       jtc /*
    594   1.1       jtc  * tar_options()
    595   1.1       jtc  *	look at the user specified flags. set globals as required and check if
    596   1.1       jtc  *	the user specified a legal set of flags. If not, complain and exit
    597   1.1       jtc  */
    598   1.1       jtc 
    599   1.1       jtc #if __STDC__
    600   1.1       jtc static void
    601   1.7       tls tar_options(int argc, char **argv)
    602   1.1       jtc #else
    603   1.1       jtc static void
    604   1.1       jtc tar_options(argc, argv)
    605   1.7       tls 	int argc;
    606   1.7       tls 	char **argv;
    607   1.1       jtc #endif
    608   1.1       jtc {
    609   1.7       tls 	int c;
    610   1.1       jtc 	int fstdin = 0;
    611   1.1       jtc 
    612   1.1       jtc 	/*
    613   1.1       jtc 	 * process option flags
    614   1.1       jtc 	 */
    615  1.10       mrg 	while ((c = getoldopt(argc, argv, "b:cef:lmoprutvwxzBC:HLPXZ014578"))
    616   1.9     lukem 	    != -1)  {
    617   1.4       jtc 		switch(c) {
    618   1.1       jtc 		case 'b':
    619   1.1       jtc 			/*
    620   1.1       jtc 			 * specify blocksize
    621   1.1       jtc 			 */
    622   1.4       jtc 			if ((wrblksz = (int)str_offt(optarg)) <= 0) {
    623   1.8  christos 				tty_warn(1, "Invalid block size %s", optarg);
    624   1.1       jtc 				tar_usage();
    625   1.1       jtc 			}
    626   1.1       jtc 			break;
    627   1.1       jtc 		case 'c':
    628   1.1       jtc 			/*
    629   1.1       jtc 			 * create an archive
    630   1.1       jtc 			 */
    631   1.1       jtc 			act = ARCHIVE;
    632   1.1       jtc 			break;
    633  1.10       mrg 		case 'C':
    634  1.10       mrg 			/*
    635  1.10       mrg 			 * chdir here before extracting.
    636  1.10       mrg 			 */
    637  1.10       mrg 			chdir_dir = optarg;
    638  1.10       mrg 			break;
    639   1.1       jtc 		case 'e':
    640   1.1       jtc 			/*
    641   1.1       jtc 			 * stop after first error
    642   1.1       jtc 			 */
    643   1.1       jtc 			maxflt = 0;
    644   1.1       jtc 			break;
    645   1.1       jtc 		case 'f':
    646   1.1       jtc 			/*
    647   1.1       jtc 			 * filename where the archive is stored
    648   1.1       jtc 			 */
    649   1.4       jtc 			if ((optarg[0] == '-') && (optarg[1]== '\0')) {
    650   1.1       jtc 				/*
    651   1.1       jtc 				 * treat a - as stdin
    652   1.1       jtc 				 */
    653   1.4       jtc 				fstdin = 1;
    654   1.1       jtc 				arcname = (char *)0;
    655   1.1       jtc 				break;
    656   1.1       jtc 			}
    657   1.1       jtc 			fstdin = 0;
    658   1.4       jtc 			arcname = optarg;
    659   1.1       jtc 			break;
    660  1.10       mrg 		case 'l':
    661  1.10       mrg 			/*
    662  1.10       mrg 			 * do not pass over mount points in the file system
    663  1.10       mrg 			 */
    664  1.10       mrg 			Xflag = 1;
    665  1.10       mrg 			break;
    666   1.1       jtc 		case 'm':
    667   1.1       jtc 			/*
    668   1.1       jtc 			 * do not preserve modification time
    669   1.1       jtc 			 */
    670   1.1       jtc 			pmtime = 0;
    671   1.1       jtc 			break;
    672   1.1       jtc 		case 'o':
    673   1.1       jtc 			if (opt_add("write_opt=nodir") < 0)
    674   1.1       jtc 				tar_usage();
    675   1.1       jtc 			break;
    676   1.1       jtc 		case 'p':
    677   1.1       jtc 			/*
    678   1.1       jtc 			 * preserve user id, group id, file
    679   1.1       jtc 			 * mode, access/modification times
    680   1.1       jtc 			 */
    681   1.1       jtc 			pids = 1;
    682   1.1       jtc 			pmode = 1;
    683   1.1       jtc 			patime = 1;
    684   1.1       jtc 			pmtime = 1;
    685   1.1       jtc 			break;
    686   1.1       jtc 		case 'r':
    687   1.1       jtc 		case 'u':
    688   1.1       jtc 			/*
    689   1.1       jtc 			 * append to the archive
    690   1.1       jtc 			 */
    691   1.1       jtc 			act = APPND;
    692   1.1       jtc 			break;
    693   1.1       jtc 		case 't':
    694   1.1       jtc 			/*
    695   1.1       jtc 			 * list contents of the tape
    696   1.1       jtc 			 */
    697   1.1       jtc 			act = LIST;
    698   1.1       jtc 			break;
    699   1.1       jtc 		case 'v':
    700   1.1       jtc 			/*
    701   1.1       jtc 			 * verbose operation mode
    702   1.1       jtc 			 */
    703   1.1       jtc 			vflag = 1;
    704   1.1       jtc 			break;
    705   1.1       jtc 		case 'w':
    706   1.1       jtc 			/*
    707   1.1       jtc 			 * interactive file rename
    708   1.1       jtc 			 */
    709   1.1       jtc 			iflag = 1;
    710   1.1       jtc 			break;
    711   1.1       jtc 		case 'x':
    712   1.1       jtc 			/*
    713   1.1       jtc 			 * write an archive
    714   1.1       jtc 			 */
    715   1.1       jtc 			act = EXTRACT;
    716   1.1       jtc 			break;
    717   1.6       mrg 		case 'z':
    718   1.6       mrg 			/*
    719   1.6       mrg 			 * use gzip.  Non standard option.
    720   1.6       mrg 			 */
    721   1.6       mrg 			zflag = 1;
    722   1.6       mrg 			gzip_program = GZIP_CMD;
    723   1.6       mrg 			break;
    724   1.1       jtc 		case 'B':
    725   1.1       jtc 			/*
    726   1.1       jtc 			 * Nothing to do here, this is pax default
    727   1.1       jtc 			 */
    728   1.1       jtc 			break;
    729   1.1       jtc 		case 'H':
    730   1.1       jtc 			/*
    731   1.1       jtc 			 * follow command line symlinks only
    732   1.1       jtc 			 */
    733   1.1       jtc 			Hflag = 1;
    734   1.1       jtc 			break;
    735   1.1       jtc 		case 'L':
    736   1.1       jtc 			/*
    737   1.1       jtc 			 * follow symlinks
    738   1.1       jtc 			 */
    739   1.1       jtc 			Lflag = 1;
    740   1.1       jtc 			break;
    741   1.1       jtc 		case 'P':
    742   1.1       jtc 			/*
    743   1.1       jtc 			 * do not follow symlinks
    744   1.1       jtc 			 */
    745   1.1       jtc 			Lflag = 0;
    746   1.1       jtc 			break;
    747   1.1       jtc 		case 'X':
    748   1.1       jtc 			/*
    749   1.1       jtc 			 * do not pass over mount points in the file system
    750   1.1       jtc 			 */
    751   1.1       jtc 			Xflag = 1;
    752   1.6       mrg 			break;
    753   1.6       mrg 		case 'Z':
    754   1.6       mrg 			/*
    755   1.6       mrg 			 * use compress.
    756   1.6       mrg 			 */
    757   1.6       mrg 			zflag = 1;
    758   1.6       mrg 			gzip_program = COMPRESS_CMD;
    759   1.1       jtc 			break;
    760   1.1       jtc 		case '0':
    761   1.1       jtc 			arcname = DEV_0;
    762   1.1       jtc 			break;
    763   1.1       jtc 		case '1':
    764   1.1       jtc 			arcname = DEV_1;
    765   1.1       jtc 			break;
    766   1.1       jtc 		case '4':
    767   1.1       jtc 			arcname = DEV_4;
    768   1.1       jtc 			break;
    769   1.1       jtc 		case '5':
    770   1.1       jtc 			arcname = DEV_5;
    771   1.1       jtc 			break;
    772   1.1       jtc 		case '7':
    773   1.1       jtc 			arcname = DEV_7;
    774   1.1       jtc 			break;
    775   1.1       jtc 		case '8':
    776   1.1       jtc 			arcname = DEV_8;
    777   1.1       jtc 			break;
    778   1.1       jtc 		default:
    779   1.1       jtc 			tar_usage();
    780   1.1       jtc 			break;
    781   1.1       jtc 		}
    782   1.1       jtc 	}
    783   1.4       jtc 	argc -= optind;
    784   1.4       jtc 	argv += optind;
    785   1.1       jtc 
    786   1.1       jtc 	/*
    787   1.1       jtc 	 * if we are writing (ARCHIVE) specify tar, otherwise run like pax
    788   1.1       jtc 	 */
    789   1.1       jtc 	if (act == ARCHIVE)
    790   1.1       jtc 		frmt = &(fsub[F_TAR]);
    791   1.1       jtc 
    792   1.1       jtc 	/*
    793   1.1       jtc 	 * process the args as they are interpreted by the operation mode
    794   1.1       jtc 	 */
    795   1.1       jtc 	switch (act) {
    796   1.1       jtc 	case LIST:
    797   1.1       jtc 	case EXTRACT:
    798   1.1       jtc 	default:
    799   1.1       jtc 		while (*argv != (char *)NULL)
    800   1.1       jtc 			if (pat_add(*argv++) < 0)
    801   1.1       jtc 				tar_usage();
    802   1.1       jtc 		break;
    803   1.1       jtc 	case ARCHIVE:
    804   1.1       jtc 	case APPND:
    805   1.1       jtc 		while (*argv != (char *)NULL)
    806   1.1       jtc 			if (ftree_add(*argv++) < 0)
    807   1.1       jtc 				tar_usage();
    808   1.1       jtc 		/*
    809   1.1       jtc 		 * no read errors allowed on updates/append operation!
    810   1.1       jtc 		 */
    811   1.1       jtc 		maxflt = 0;
    812   1.1       jtc 		break;
    813   1.1       jtc 	}
    814   1.1       jtc 	if (!fstdin && ((arcname == (char *)NULL) || (*arcname == '\0'))) {
    815   1.1       jtc 		arcname = getenv("TAPE");
    816   1.1       jtc 		if ((arcname == (char *)NULL) || (*arcname == '\0'))
    817   1.1       jtc 			arcname = DEV_8;
    818   1.1       jtc 	}
    819   1.1       jtc }
    820   1.1       jtc 
    821   1.1       jtc /*
    822   1.1       jtc  * cpio_options()
    823   1.1       jtc  *	look at the user specified flags. set globals as required and check if
    824   1.1       jtc  *	the user specified a legal set of flags. If not, complain and exit
    825   1.1       jtc  */
    826   1.1       jtc 
    827   1.1       jtc #if __STDC__
    828   1.1       jtc static void
    829   1.7       tls cpio_options(int argc, char **argv)
    830   1.1       jtc #else
    831   1.1       jtc static void
    832   1.1       jtc cpio_options(argc, argv)
    833   1.7       tls 	int argc;
    834   1.7       tls 	char **argv;
    835   1.1       jtc #endif
    836   1.1       jtc {
    837  1.10       mrg         FSUB tmp;
    838  1.10       mrg 	unsigned int flg = 0;
    839  1.10       mrg 	unsigned int bflg = 0;
    840  1.10       mrg 	int c, i;
    841  1.10       mrg 
    842  1.10       mrg 	cpio_mode = uflag = 1;
    843  1.10       mrg 	/*
    844  1.10       mrg 	 * process option flags
    845  1.10       mrg 	 */
    846  1.10       mrg 	while ((c = getoldopt(argc, argv, "ABC:E:H:I:LM:O:R:SVabcdfiklmoprstuv"))
    847  1.10       mrg 	    != -1)  {
    848  1.10       mrg 		switch(c) {
    849  1.10       mrg 		case 'A':
    850  1.10       mrg 			/*
    851  1.10       mrg 			 * append to an archive
    852  1.10       mrg 			 */
    853  1.10       mrg 			act = APPND;
    854  1.10       mrg 			flg |= AF;
    855  1.10       mrg 			break;
    856  1.10       mrg 		case 'B':
    857  1.10       mrg 			/*
    858  1.10       mrg 			 * set blocksize to 5120
    859  1.10       mrg 			 */
    860  1.10       mrg 			blksz = 5120;
    861  1.10       mrg 			break;
    862  1.10       mrg 		case 'C':
    863  1.10       mrg 			/*
    864  1.10       mrg 			 * specify blocksize
    865  1.10       mrg 			 */
    866  1.10       mrg 			if ((blksz = (int)str_offt(optarg)) <= 0) {
    867  1.10       mrg 				tty_warn(1, "Invalid block size %s", optarg);
    868  1.10       mrg 				tar_usage();
    869  1.10       mrg 			}
    870  1.10       mrg 			break;
    871  1.10       mrg #ifdef notyet
    872  1.10       mrg 		case 'E':
    873  1.10       mrg 			arg = optarg;
    874  1.10       mrg 			break;
    875  1.10       mrg #endif
    876  1.10       mrg 		case 'H':
    877  1.10       mrg 			/*
    878  1.10       mrg 			 * specify an archive format on write
    879  1.10       mrg 			 */
    880  1.10       mrg 			tmp.name = optarg;
    881  1.10       mrg 			frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
    882  1.10       mrg 			    sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt);
    883  1.10       mrg 			if (frmt != NULL) {
    884  1.10       mrg 				flg |= XF;
    885  1.10       mrg 				break;
    886  1.10       mrg 			}
    887  1.10       mrg 			tty_warn(1, "Unknown -H format: %s", optarg);
    888  1.10       mrg 			(void)fputs("cpio: Known -H formats are:", stderr);
    889  1.10       mrg 			for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
    890  1.10       mrg 				(void)fprintf(stderr, " %s", fsub[i].name);
    891  1.10       mrg 			(void)fputs("\n\n", stderr);
    892  1.10       mrg 			tar_usage();
    893  1.10       mrg 			break;
    894  1.10       mrg 		case 'I':
    895  1.10       mrg 		case 'O':
    896  1.10       mrg 			/*
    897  1.10       mrg 			 * filename where the archive is stored
    898  1.10       mrg 			 */
    899  1.10       mrg 			if ((optarg[0] == '-') && (optarg[1]== '\0')) {
    900  1.10       mrg 				/*
    901  1.10       mrg 				 * treat a - as stdin
    902  1.10       mrg 				 */
    903  1.10       mrg 				arcname = (char *)0;
    904  1.10       mrg 				break;
    905  1.10       mrg 			}
    906  1.10       mrg 			arcname = optarg;
    907  1.10       mrg 			break;
    908  1.10       mrg 		case 'L':
    909  1.10       mrg 			/*
    910  1.10       mrg 			 * follow symlinks
    911  1.10       mrg 			 */
    912  1.10       mrg 			Lflag = 1;
    913  1.10       mrg 			flg |= CLF;
    914  1.10       mrg 			break;
    915  1.10       mrg #ifdef notyet
    916  1.10       mrg 		case 'M':
    917  1.10       mrg 			arg = optarg;
    918  1.10       mrg 			break;
    919  1.10       mrg 		case 'R':
    920  1.10       mrg 			arg = optarg;
    921  1.10       mrg 			break;
    922  1.10       mrg #endif
    923  1.10       mrg 		case 'S':
    924  1.10       mrg 			cpio_swp_head = 1;
    925  1.10       mrg 			break;
    926  1.10       mrg #ifdef notyet
    927  1.10       mrg 		case 'V':
    928  1.10       mrg 			break;
    929  1.10       mrg #endif
    930  1.10       mrg 		case 'a':
    931  1.10       mrg 			/*
    932  1.10       mrg 			 * preserve access time on filesystem nodes we read
    933  1.10       mrg 			 */
    934  1.10       mrg 			tflag = 1;
    935  1.10       mrg 			flg |= TF;
    936  1.10       mrg 			break;
    937  1.10       mrg #ifdef notyet
    938  1.10       mrg 		case 'b':
    939  1.10       mrg 			break;
    940  1.10       mrg #endif
    941  1.10       mrg 		case 'c':
    942  1.10       mrg 			frmt = &fsub[F_SV4CPIO];
    943  1.10       mrg 			break;
    944  1.10       mrg 		case 'd':
    945  1.10       mrg 			/*
    946  1.10       mrg 			 * pax does this by default ..
    947  1.10       mrg 			 */
    948  1.10       mrg 			flg |= RF;
    949  1.10       mrg 			break;
    950  1.10       mrg 		case 'f':
    951  1.10       mrg 			/*
    952  1.10       mrg 			 * inverse match on patterns
    953  1.10       mrg 			 */
    954  1.10       mrg 			cflag = 1;
    955  1.10       mrg 			flg |= CF;
    956  1.10       mrg 			break;
    957  1.10       mrg 		case 'i':
    958  1.10       mrg 			/*
    959  1.10       mrg 			 * read the archive
    960  1.10       mrg 			 */
    961  1.10       mrg 			flg |= RF;
    962  1.10       mrg 			break;
    963  1.10       mrg #ifdef notyet
    964  1.10       mrg 		case 'k':
    965  1.10       mrg 			break;
    966  1.10       mrg #endif
    967  1.10       mrg 		case 'l':
    968  1.10       mrg 			/*
    969  1.10       mrg 			 * try to link src to dest with copy (-rw)
    970  1.10       mrg 			 */
    971  1.10       mrg 			lflag = 1;
    972  1.10       mrg 			flg |= LF;
    973  1.10       mrg 			break;
    974  1.10       mrg 		case 'm':
    975  1.10       mrg 			/*
    976  1.10       mrg 			 * preserve mtime
    977  1.10       mrg 			 */
    978  1.10       mrg 			flg |= PF;
    979  1.10       mrg 			pmtime = 1;
    980  1.10       mrg 			break;
    981  1.10       mrg 		case 'o':
    982  1.10       mrg 			/*
    983  1.10       mrg 			 * write an archive
    984  1.10       mrg 			 */
    985  1.10       mrg 			flg |= WF;
    986  1.10       mrg 			break;
    987  1.10       mrg 		case 'p':
    988  1.10       mrg 			/*
    989  1.10       mrg 			 * cpio -p is like pax -rw
    990  1.10       mrg 			 */
    991  1.10       mrg 			flg |= RF | WF;
    992  1.10       mrg 			break;
    993  1.10       mrg 		case 'r':
    994  1.10       mrg 			/*
    995  1.10       mrg 			 * interactive file rename
    996  1.10       mrg 			 */
    997  1.10       mrg 			iflag = 1;
    998  1.10       mrg 			flg |= IF;
    999  1.10       mrg 			break;
   1000  1.10       mrg #ifdef notyet
   1001  1.10       mrg 		case 's':
   1002  1.10       mrg 			break;
   1003  1.10       mrg #endif
   1004  1.10       mrg 		case 't':
   1005  1.10       mrg 			act = LIST;
   1006  1.10       mrg 			break;
   1007  1.10       mrg 		case 'u':
   1008  1.10       mrg 			/*
   1009  1.10       mrg 			 * don't ignore those older files
   1010  1.10       mrg 			 */
   1011  1.10       mrg 			uflag = 0;
   1012  1.10       mrg 			flg |= UF;
   1013  1.10       mrg 			break;
   1014  1.10       mrg 		case 'v':
   1015  1.10       mrg 			/*
   1016  1.10       mrg 			 * verbose operation mode
   1017  1.10       mrg 			 */
   1018  1.10       mrg 			vflag = 1;
   1019  1.10       mrg 			flg |= VF;
   1020  1.10       mrg 			break;
   1021  1.10       mrg 		default:
   1022  1.10       mrg 			cpio_usage();
   1023  1.10       mrg 			break;
   1024  1.10       mrg 		}
   1025  1.10       mrg 	}
   1026  1.10       mrg 
   1027  1.10       mrg 	/*
   1028  1.10       mrg 	 * figure out the operation mode of cpio. check that we have not been
   1029  1.10       mrg 	 * given a bogus set of flags for the operation mode.
   1030  1.10       mrg 	 */
   1031  1.10       mrg 	if (ISLIST(flg)) {
   1032  1.10       mrg 		act = LIST;
   1033  1.10       mrg 		bflg = flg & BDLIST;
   1034  1.10       mrg 	} else if (ISEXTRACT(flg)) {
   1035  1.10       mrg 		act = EXTRACT;
   1036  1.10       mrg 		bflg = flg & BDEXTR;
   1037  1.10       mrg 	} else if (ISARCHIVE(flg)) {
   1038  1.10       mrg 		act = ARCHIVE;
   1039  1.10       mrg 		bflg = flg & BDARCH;
   1040  1.10       mrg 	} else if (ISAPPND(flg)) {
   1041  1.10       mrg 		act = APPND;
   1042  1.10       mrg 		bflg = flg & BDARCH;
   1043  1.10       mrg 	} else if (ISCOPY(flg)) {
   1044  1.10       mrg 		act = COPY;
   1045  1.10       mrg 		bflg = flg & BDCOPY;
   1046  1.10       mrg 	} else
   1047  1.10       mrg 		cpio_usage();
   1048  1.10       mrg 	if (bflg) {
   1049  1.10       mrg 		cpio_usage();
   1050  1.10       mrg 	}
   1051  1.10       mrg 
   1052  1.10       mrg 	/*
   1053  1.10       mrg 	 * if we are writing (ARCHIVE) we use the default format if the user
   1054  1.10       mrg 	 * did not specify a format. when we write during an APPEND, we will
   1055  1.10       mrg 	 * adopt the format of the existing archive if none was supplied.
   1056  1.10       mrg 	 */
   1057  1.10       mrg 	if (!(flg & XF) && (act == ARCHIVE))
   1058  1.10       mrg 		frmt = &(fsub[F_BCPIO]);
   1059  1.10       mrg 
   1060  1.10       mrg 	/*
   1061  1.10       mrg 	 * process the args as they are interpreted by the operation mode
   1062  1.10       mrg 	 */
   1063  1.10       mrg 	switch (act) {
   1064  1.10       mrg 	case LIST:
   1065  1.10       mrg 	case EXTRACT:
   1066  1.10       mrg 		for (; optind < argc; optind++)
   1067  1.10       mrg 			if (pat_add(argv[optind]) < 0)
   1068  1.10       mrg 				cpio_usage();
   1069  1.10       mrg 		break;
   1070  1.10       mrg 	case COPY:
   1071  1.10       mrg 		if (optind >= argc) {
   1072  1.10       mrg 			tty_warn(0, "Destination directory was not supplied");
   1073  1.10       mrg 			cpio_usage();
   1074  1.10       mrg 		}
   1075  1.10       mrg 		--argc;
   1076  1.10       mrg 		dirptr = argv[argc];
   1077  1.10       mrg 		/* FALL THROUGH */
   1078  1.10       mrg 	case ARCHIVE:
   1079  1.10       mrg 	case APPND:
   1080  1.10       mrg 		for (; optind < argc; optind++)
   1081  1.10       mrg 			if (ftree_add(argv[optind]) < 0)
   1082  1.10       mrg 				cpio_usage();
   1083  1.10       mrg 		/*
   1084  1.10       mrg 		 * no read errors allowed on updates/append operation!
   1085  1.10       mrg 		 */
   1086  1.10       mrg 		maxflt = 0;
   1087  1.10       mrg 		break;
   1088  1.10       mrg 	}
   1089   1.1       jtc }
   1090   1.1       jtc 
   1091   1.1       jtc /*
   1092   1.1       jtc  * printflg()
   1093   1.1       jtc  *	print out those invalid flag sets found to the user
   1094   1.1       jtc  */
   1095   1.1       jtc 
   1096   1.1       jtc #if __STDC__
   1097   1.1       jtc static void
   1098   1.1       jtc printflg(unsigned int flg)
   1099   1.1       jtc #else
   1100   1.1       jtc static void
   1101   1.1       jtc printflg(flg)
   1102   1.1       jtc 	unsigned int flg;
   1103   1.1       jtc #endif
   1104   1.1       jtc {
   1105   1.1       jtc 	int nxt;
   1106   1.1       jtc 	int pos = 0;
   1107   1.1       jtc 
   1108   1.1       jtc 	(void)fprintf(stderr,"%s: Invalid combination of options:", argv0);
   1109   1.8  christos 	while ((nxt = ffs(flg)) != 0) {
   1110   1.1       jtc 		flg = flg >> nxt;
   1111   1.1       jtc 		pos += nxt;
   1112   1.1       jtc 		(void)fprintf(stderr, " -%c", flgch[pos-1]);
   1113   1.1       jtc 	}
   1114   1.1       jtc 	(void)putc('\n', stderr);
   1115   1.1       jtc }
   1116   1.1       jtc 
   1117   1.1       jtc /*
   1118   1.1       jtc  * c_frmt()
   1119   1.1       jtc  *	comparison routine used by bsearch to find the format specified
   1120   1.1       jtc  *	by the user
   1121   1.1       jtc  */
   1122   1.1       jtc 
   1123   1.1       jtc #if __STDC__
   1124   1.1       jtc static int
   1125   1.1       jtc c_frmt(const void *a, const void *b)
   1126   1.1       jtc #else
   1127   1.1       jtc static int
   1128   1.1       jtc c_frmt(a, b)
   1129   1.1       jtc         void *a;
   1130   1.1       jtc         void *b;
   1131   1.1       jtc #endif
   1132   1.1       jtc {
   1133   1.1       jtc         return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name));
   1134   1.1       jtc }
   1135   1.1       jtc 
   1136   1.1       jtc /*
   1137   1.1       jtc  * opt_next()
   1138   1.1       jtc  *	called by format specific options routines to get each format specific
   1139   1.1       jtc  *	flag and value specified with -o
   1140   1.1       jtc  * Return:
   1141   1.1       jtc  *	pointer to next OPLIST entry or NULL (end of list).
   1142   1.1       jtc  */
   1143   1.1       jtc 
   1144   1.1       jtc #if __STDC__
   1145   1.1       jtc OPLIST *
   1146   1.1       jtc opt_next(void)
   1147   1.1       jtc #else
   1148   1.1       jtc OPLIST *
   1149   1.1       jtc opt_next()
   1150   1.1       jtc #endif
   1151   1.1       jtc {
   1152   1.1       jtc 	OPLIST *opt;
   1153   1.1       jtc 
   1154   1.1       jtc 	if ((opt = ophead) != NULL)
   1155   1.1       jtc 		ophead = ophead->fow;
   1156   1.1       jtc 	return(opt);
   1157   1.1       jtc }
   1158   1.1       jtc 
   1159   1.1       jtc /*
   1160   1.1       jtc  * bad_opt()
   1161   1.1       jtc  *	generic routine used to complain about a format specific options
   1162   1.1       jtc  *	when the format does not support options.
   1163   1.1       jtc  */
   1164   1.1       jtc 
   1165   1.1       jtc #if __STDC__
   1166   1.1       jtc int
   1167   1.1       jtc bad_opt(void)
   1168   1.1       jtc #else
   1169   1.1       jtc int
   1170   1.1       jtc bad_opt()
   1171   1.1       jtc #endif
   1172   1.1       jtc {
   1173   1.7       tls 	OPLIST *opt;
   1174   1.1       jtc 
   1175   1.1       jtc 	if (ophead == NULL)
   1176   1.1       jtc 		return(0);
   1177   1.1       jtc 	/*
   1178   1.1       jtc 	 * print all we were given
   1179   1.1       jtc 	 */
   1180   1.8  christos 	tty_warn(1,"These format options are not supported");
   1181   1.1       jtc 	while ((opt = opt_next()) != NULL)
   1182   1.1       jtc 		(void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value);
   1183   1.1       jtc 	pax_usage();
   1184   1.1       jtc 	return(0);
   1185   1.1       jtc }
   1186   1.1       jtc 
   1187   1.1       jtc /*
   1188   1.1       jtc  * opt_add()
   1189   1.1       jtc  *	breaks the value supplied to -o into a option name and value. options
   1190   1.1       jtc  *	are given to -o in the form -o name-value,name=value
   1191   1.1       jtc  *	mulltiple -o may be specified.
   1192   1.1       jtc  * Return:
   1193   1.1       jtc  *	0 if format in name=value format, -1 if -o is passed junk
   1194   1.1       jtc  */
   1195   1.1       jtc 
   1196   1.1       jtc #if __STDC__
   1197   1.1       jtc int
   1198   1.7       tls opt_add(char *str)
   1199   1.1       jtc #else
   1200   1.1       jtc int
   1201   1.1       jtc opt_add(str)
   1202   1.7       tls 	char *str;
   1203   1.1       jtc #endif
   1204   1.1       jtc {
   1205   1.7       tls 	OPLIST *opt;
   1206   1.7       tls 	char *frpt;
   1207   1.7       tls 	char *pt;
   1208   1.7       tls 	char *endpt;
   1209   1.1       jtc 
   1210   1.1       jtc 	if ((str == NULL) || (*str == '\0')) {
   1211   1.8  christos 		tty_warn(0, "Invalid option name");
   1212   1.1       jtc 		return(-1);
   1213   1.1       jtc 	}
   1214   1.1       jtc 	frpt = endpt = str;
   1215   1.1       jtc 
   1216   1.1       jtc 	/*
   1217   1.1       jtc 	 * break into name and values pieces and stuff each one into a
   1218   1.1       jtc 	 * OPLIST structure. When we know the format, the format specific
   1219   1.1       jtc 	 * option function will go through this list
   1220   1.1       jtc 	 */
   1221   1.1       jtc 	while ((frpt != NULL) && (*frpt != '\0')) {
   1222   1.1       jtc 		if ((endpt = strchr(frpt, ',')) != NULL)
   1223   1.1       jtc 			*endpt = '\0';
   1224   1.1       jtc 		if ((pt = strchr(frpt, '=')) == NULL) {
   1225   1.8  christos 			tty_warn(0, "Invalid options format");
   1226   1.1       jtc 			return(-1);
   1227   1.1       jtc 		}
   1228   1.1       jtc 		if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) {
   1229   1.8  christos 			tty_warn(0, "Unable to allocate space for option list");
   1230   1.1       jtc 			return(-1);
   1231   1.1       jtc 		}
   1232   1.1       jtc 		*pt++ = '\0';
   1233   1.1       jtc 		opt->name = frpt;
   1234   1.1       jtc 		opt->value = pt;
   1235   1.1       jtc 		opt->fow = NULL;
   1236   1.1       jtc 		if (endpt != NULL)
   1237   1.1       jtc 			frpt = endpt + 1;
   1238   1.1       jtc 		else
   1239   1.1       jtc 			frpt = NULL;
   1240   1.1       jtc 		if (ophead == NULL) {
   1241   1.1       jtc 			optail = ophead = opt;
   1242   1.1       jtc 			continue;
   1243   1.1       jtc 		}
   1244   1.1       jtc 		optail->fow = opt;
   1245   1.1       jtc 		optail = opt;
   1246   1.1       jtc 	}
   1247   1.1       jtc 	return(0);
   1248   1.1       jtc }
   1249   1.1       jtc 
   1250   1.1       jtc /*
   1251   1.1       jtc  * str_offt()
   1252   1.1       jtc  *	Convert an expression of the following forms to an off_t > 0.
   1253   1.1       jtc  * 	1) A positive decimal number.
   1254   1.1       jtc  *	2) A positive decimal number followed by a b (mult by 512).
   1255   1.1       jtc  *	3) A positive decimal number followed by a k (mult by 1024).
   1256   1.1       jtc  *	4) A positive decimal number followed by a m (mult by 512).
   1257   1.1       jtc  *	5) A positive decimal number followed by a w (mult by sizeof int)
   1258   1.1       jtc  *	6) Two or more positive decimal numbers (with/without k,b or w).
   1259   1.1       jtc  *	   seperated by x (also * for backwards compatibility), specifying
   1260   1.1       jtc  *	   the product of the indicated values.
   1261   1.1       jtc  * Return:
   1262   1.1       jtc  *	0 for an error, a positive value o.w.
   1263   1.1       jtc  */
   1264   1.1       jtc 
   1265   1.1       jtc #if __STDC__
   1266   1.1       jtc static off_t
   1267   1.1       jtc str_offt(char *val)
   1268   1.1       jtc #else
   1269   1.1       jtc static off_t
   1270   1.1       jtc str_offt(val)
   1271   1.1       jtc 	char *val;
   1272   1.1       jtc #endif
   1273   1.1       jtc {
   1274   1.1       jtc 	char *expr;
   1275   1.1       jtc 	off_t num, t;
   1276   1.1       jtc 
   1277   1.1       jtc #	ifdef NET2_STAT
   1278   1.1       jtc 	num = strtol(val, &expr, 0);
   1279   1.1       jtc 	if ((num == LONG_MAX) || (num <= 0) || (expr == val))
   1280   1.1       jtc #	else
   1281   1.1       jtc 	num = strtoq(val, &expr, 0);
   1282   1.1       jtc 	if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
   1283   1.1       jtc #	endif
   1284   1.1       jtc 		return(0);
   1285   1.1       jtc 
   1286   1.1       jtc 	switch(*expr) {
   1287   1.1       jtc 	case 'b':
   1288   1.1       jtc 		t = num;
   1289   1.1       jtc 		num *= 512;
   1290   1.1       jtc 		if (t > num)
   1291   1.1       jtc 			return(0);
   1292   1.1       jtc 		++expr;
   1293   1.1       jtc 		break;
   1294   1.1       jtc 	case 'k':
   1295   1.1       jtc 		t = num;
   1296   1.1       jtc 		num *= 1024;
   1297   1.1       jtc 		if (t > num)
   1298   1.1       jtc 			return(0);
   1299   1.1       jtc 		++expr;
   1300   1.1       jtc 		break;
   1301   1.1       jtc 	case 'm':
   1302   1.1       jtc 		t = num;
   1303   1.1       jtc 		num *= 1048576;
   1304   1.1       jtc 		if (t > num)
   1305   1.1       jtc 			return(0);
   1306   1.1       jtc 		++expr;
   1307   1.1       jtc 		break;
   1308   1.1       jtc 	case 'w':
   1309   1.1       jtc 		t = num;
   1310   1.1       jtc 		num *= sizeof(int);
   1311   1.1       jtc 		if (t > num)
   1312   1.1       jtc 			return(0);
   1313   1.1       jtc 		++expr;
   1314   1.1       jtc 		break;
   1315   1.1       jtc 	}
   1316   1.1       jtc 
   1317   1.1       jtc 	switch(*expr) {
   1318   1.1       jtc 		case '\0':
   1319   1.1       jtc 			break;
   1320   1.1       jtc 		case '*':
   1321   1.1       jtc 		case 'x':
   1322   1.1       jtc 			t = num;
   1323   1.1       jtc 			num *= str_offt(expr + 1);
   1324   1.1       jtc 			if (t > num)
   1325   1.1       jtc 				return(0);
   1326   1.1       jtc 			break;
   1327   1.1       jtc 		default:
   1328   1.1       jtc 			return(0);
   1329   1.1       jtc 	}
   1330   1.1       jtc 	return(num);
   1331   1.1       jtc }
   1332   1.1       jtc 
   1333   1.1       jtc /*
   1334   1.1       jtc  * no_op()
   1335   1.1       jtc  *	for those option functions where the archive format has nothing to do.
   1336   1.1       jtc  * Return:
   1337   1.1       jtc  *	0
   1338   1.1       jtc  */
   1339   1.1       jtc 
   1340   1.1       jtc #if __STDC__
   1341   1.1       jtc static int
   1342   1.1       jtc no_op(void)
   1343   1.1       jtc #else
   1344   1.1       jtc static int
   1345   1.1       jtc no_op()
   1346   1.1       jtc #endif
   1347   1.1       jtc {
   1348   1.1       jtc 	return(0);
   1349   1.1       jtc }
   1350   1.1       jtc 
   1351   1.1       jtc /*
   1352   1.1       jtc  * pax_usage()
   1353   1.1       jtc  *	print the usage summary to the user
   1354   1.1       jtc  */
   1355   1.1       jtc 
   1356   1.1       jtc #if __STDC__
   1357   1.1       jtc void
   1358   1.1       jtc pax_usage(void)
   1359   1.1       jtc #else
   1360   1.1       jtc void
   1361   1.1       jtc pax_usage()
   1362   1.1       jtc #endif
   1363   1.1       jtc {
   1364   1.1       jtc 	(void)fputs("usage: pax [-cdnv] [-E limit] [-f archive] ", stderr);
   1365   1.1       jtc 	(void)fputs("[-s replstr] ... [-U user] ...", stderr);
   1366   1.1       jtc 	(void)fputs("\n           [-G group] ... ", stderr);
   1367   1.1       jtc 	(void)fputs("[-T [from_date][,to_date]] ... ", stderr);
   1368   1.1       jtc 	(void)fputs("[pattern ...]\n", stderr);
   1369   1.1       jtc 	(void)fputs("       pax -r [-cdiknuvDYZ] [-E limit] ", stderr);
   1370   1.1       jtc 	(void)fputs("[-f archive] [-o options] ... \n", stderr);
   1371   1.1       jtc 	(void)fputs("           [-p string] ... [-s replstr] ... ", stderr);
   1372   1.1       jtc 	(void)fputs("[-U user] ... [-G group] ...\n           ", stderr);
   1373   1.1       jtc 	(void)fputs("[-T [from_date][,to_date]] ... ", stderr);
   1374   1.1       jtc 	(void)fputs(" [pattern ...]\n", stderr);
   1375   1.1       jtc 	(void)fputs("       pax -w [-dituvHLPX] [-b blocksize] ", stderr);
   1376   1.1       jtc 	(void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr);
   1377   1.1       jtc 	(void)fputs("           [-B bytes] [-s replstr] ... ", stderr);
   1378   1.1       jtc 	(void)fputs("[-o options] ... [-U user] ...", stderr);
   1379   1.1       jtc 	(void)fputs("\n           [-G group] ... ", stderr);
   1380   1.1       jtc 	(void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr);
   1381   1.1       jtc 	(void)fputs("[file ...]\n", stderr);
   1382   1.1       jtc 	(void)fputs("       pax -r -w [-diklntuvDHLPXYZ] ", stderr);
   1383   1.1       jtc 	(void)fputs("[-p string] ... [-s replstr] ...", stderr);
   1384   1.1       jtc 	(void)fputs("\n           [-U user] ... [-G group] ... ", stderr);
   1385   1.1       jtc 	(void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr);
   1386   1.1       jtc 	(void)fputs("\n           [file ...] directory\n", stderr);
   1387   1.1       jtc 	exit(1);
   1388  1.12   mycroft 	/* NOTREACHED */
   1389   1.1       jtc }
   1390   1.1       jtc 
   1391   1.1       jtc /*
   1392   1.1       jtc  * tar_usage()
   1393   1.1       jtc  *	print the usage summary to the user
   1394   1.1       jtc  */
   1395   1.1       jtc 
   1396   1.1       jtc #if __STDC__
   1397   1.1       jtc void
   1398   1.1       jtc tar_usage(void)
   1399   1.1       jtc #else
   1400   1.1       jtc void
   1401   1.1       jtc tar_usage()
   1402   1.1       jtc #endif
   1403   1.1       jtc {
   1404  1.10       mrg 	(void)fputs("usage: tar -{txru}[cevfblmopwBHLPX014578] [tapefile] ",
   1405   1.1       jtc 		 stderr);
   1406   1.1       jtc 	(void)fputs("[blocksize] file1 file2...\n", stderr);
   1407   1.1       jtc 	exit(1);
   1408  1.12   mycroft 	/* NOTREACHED */
   1409   1.1       jtc }
   1410   1.1       jtc 
   1411   1.1       jtc /*
   1412   1.1       jtc  * cpio_usage()
   1413   1.1       jtc  *	print the usage summary to the user
   1414   1.1       jtc  */
   1415   1.1       jtc 
   1416   1.1       jtc #if __STDC__
   1417   1.1       jtc void
   1418   1.1       jtc cpio_usage(void)
   1419   1.1       jtc #else
   1420   1.1       jtc void
   1421   1.1       jtc cpio_usage()
   1422   1.1       jtc #endif
   1423   1.1       jtc {
   1424  1.10       mrg 
   1425  1.10       mrg #if 1
   1426  1.10       mrg 	(void)fputs(
   1427  1.10       mrg 	    "usage: cpio -i [-BcdfmrStuv] [ -C blksize ] [ -H header ]\n",
   1428  1.10       mrg 	    stderr);
   1429  1.10       mrg 	(void)fputs("  [ -I file ] [ pattern ... ]\n", stderr);
   1430  1.10       mrg 	(void)fputs("usage: cpio -o [-aABcLv] [ -C bufsize ] [ -H header ]\n",
   1431  1.10       mrg 	    stderr);
   1432  1.10       mrg 	(void)fputs("  [ -O file ]\n", stderr);
   1433  1.10       mrg 	(void)fputs("usage: cpio -p [ adlLmuv ] directory\n", stderr);
   1434  1.10       mrg #else
   1435  1.10       mrg 	/* no E, M, R, V, b, k or s */
   1436  1.10       mrg 	(void)fputs("usage: cpio -i [-bBcdfkmrsStuvV] [ -C bufsize ]\n", stderr);
   1437  1.10       mrg 	(void)fputs("  [ -E file ] [ -H header ] [ -I file [ -M message ] ]\n",
   1438  1.10       mrg 	    stderr);
   1439  1.10       mrg 	(void)fputs("  [ -R id ] [ pattern ... ]\n", stderr);
   1440  1.10       mrg 	(void)fputs("usage: cpio -o [-aABcLvV] [ -C bufsize ] [ -H header ]\n",
   1441  1.10       mrg 	    stderr);
   1442  1.10       mrg 	(void)fputs("  [ -O file [ -M message ] ]\n", stderr);
   1443  1.10       mrg 	(void)fputs("usage: cpio -p [ adlLmuvV ] [ -R id ] directory\n", stderr);
   1444  1.10       mrg #endif
   1445   1.1       jtc 	exit(1);
   1446  1.12   mycroft 	/* NOTREACHED */
   1447   1.1       jtc }
   1448