source: freewrt/tools/paxmirabilis/src/options.c@ b862906

freewrt_1_0 freewrt_2_0
Last change on this file since b862906 was b862906, checked in by Thorsten Glaser <tg@…>, 19 years ago

long long instead of quad

git-svn-id: svn://www.freewrt.org/trunk/freewrt@213 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 35.2 KB
Line 
1/** $MirOS: src/bin/pax/options.c,v 1.18 2006/07/16 16:14:50 tg Exp $ */
2/* $OpenBSD: options.c,v 1.64 2006/04/09 03:35:34 jaredy Exp $ */
3/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
4
5/*-
6 * Copyright (c) 2005, 2006 Thorsten Glaser <tg@66h.42h.de>
7 * Copyright (c) 1992 Keith Muller.
8 * Copyright (c) 1992, 1993
9 * The Regents of the University of California. All rights reserved.
10 *
11 * This code is derived from software contributed to Berkeley by
12 * Keith Muller of the University of California, San Diego.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39#include <sys/param.h>
40#include <sys/time.h>
41#include <sys/stat.h>
42#ifndef __INTERIX
43#include <sys/mtio.h>
44#endif
45#include <stdio.h>
46#include <string.h>
47#include <err.h>
48#include <errno.h>
49#include <unistd.h>
50#include <stdlib.h>
51#include <limits.h>
52#include <paths.h>
53#include "pax.h"
54#include "options.h"
55#include "cpio.h"
56#include "tar.h"
57#include "extern.h"
58
59__SCCSID("@(#)options.c 8.2 (Berkeley) 4/18/94");
60__RCSID("$MirOS: src/bin/pax/options.c,v 1.18 2006/07/16 16:14:50 tg Exp $");
61
62/*
63 * Routines which handle command line options
64 */
65
66static char flgch[] = FLGCH; /* list of all possible flags */
67static OPLIST *ophead = NULL; /* head for format specific options -x */
68static OPLIST *optail = NULL; /* option tail */
69
70static int no_op(void);
71static void printflg(unsigned int);
72static int c_frmt(const void *, const void *);
73static off_t str_offt(char *);
74static char *getline(FILE *fp);
75static void pax_options(int, char **);
76static void pax_usage(void);
77static void tar_options(int, char **);
78static void tar_usage(void);
79static void cpio_options(int, char **);
80static void cpio_usage(void);
81int mkpath(char *);
82
83static void process_M(const char *, void (*)(void));
84
85/* errors from getline */
86#define GETLINE_FILE_CORRUPT 1
87#define GETLINE_OUT_OF_MEM 2
88static int getline_error;
89
90
91#define GZIP_CMD "gzip" /* command to run as gzip */
92#define COMPRESS_CMD "compress" /* command to run as compress */
93
94/*
95 * Format specific routine table - MUST BE IN SORTED ORDER BY NAME
96 * (see pax.h for description of each function)
97 *
98 * name, blksz, hdsz, udev, hlk, blkagn, inhead, id, st_read,
99 * read, end_read, st_write, write, end_write, trail,
100 * rd_data, wr_data, options
101 */
102
103FSUB fsub[] = {
104/* 0: OLD BINARY CPIO */
105 {"bcpio", 5120, sizeof(HD_BCPIO), 1, 0, 0, 1, bcpio_id, cpio_strd,
106 bcpio_rd, bcpio_endrd, cpio_stwr, bcpio_wr, cpio_endwr, cpio_trail,
107 rd_wrfile, wr_rdfile, bad_opt},
108
109/* 1: OLD OCTAL CHARACTER CPIO */
110 {"cpio", 5120, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd,
111 cpio_rd, cpio_endrd, cpio_stwr, cpio_wr, cpio_endwr, cpio_trail,
112 rd_wrfile, wr_rdfile, bad_opt},
113
114/* 2: OLD OCTAL CHARACTER CPIO, UID/GID CLEARED (ANONYMISED) */
115 {"dist", 512, sizeof(HD_CPIO), 1, 0, 0, 1, cpio_id, cpio_strd,
116 cpio_rd, cpio_endrd, dist_stwr, cpio_wr, cpio_endwr, cpio_trail,
117 rd_wrfile, wr_rdfile, bad_opt},
118
119/* 3: SVR4 HEX CPIO */
120 {"sv4cpio", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, vcpio_id, cpio_strd,
121 vcpio_rd, vcpio_endrd, cpio_stwr, vcpio_wr, cpio_endwr, cpio_trail,
122 rd_wrfile, wr_rdfile, bad_opt},
123
124/* 4: SVR4 HEX CPIO WITH CRC */
125 {"sv4crc", 5120, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd,
126 vcpio_rd, vcpio_endrd, crc_stwr, vcpio_wr, cpio_endwr, cpio_trail,
127 rd_wrfile, wr_rdfile, bad_opt},
128
129/* 5: OLD TAR */
130 {"tar", 10240, BLKMULT, 0, 1, BLKMULT, 0, tar_id, no_op,
131 tar_rd, tar_endrd, no_op, tar_wr, tar_endwr, tar_trail,
132 rd_wrfile, wr_rdfile, tar_opt},
133
134/* 6: POSIX USTAR */
135 {"ustar", 10240, BLKMULT, 0, 1, BLKMULT, 0, ustar_id, ustar_strd,
136 ustar_rd, tar_endrd, ustar_stwr, ustar_wr, tar_endwr, tar_trail,
137 rd_wrfile, wr_rdfile, bad_opt},
138
139/* 7: SVR4 HEX CPIO WITH CRC, UID/GID/MTIME CLEARED (NORMALISED) */
140 {"v4norm", 512, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd,
141 vcpio_rd, vcpio_endrd, v4norm_stwr, vcpio_wr, cpio_endwr, cpio_trail,
142 rd_wrfile, wr_rdfile, bad_opt},
143
144/* 8: SVR4 HEX CPIO WITH CRC, UID/GID CLEARED (ANONYMISED) */
145 {"v4root", 512, sizeof(HD_VCPIO), 1, 0, 0, 1, crc_id, crc_strd,
146 vcpio_rd, vcpio_endrd, v4root_stwr, vcpio_wr, cpio_endwr, cpio_trail,
147 rd_wrfile, wr_rdfile, bad_opt},
148};
149#define F_OCPIO 0 /* format when called as cpio -6 */
150#define F_ACPIO 1 /* format when called as cpio -c */
151#define F_NCPIO 3 /* format when called as tar -R */
152#define F_CPIO 4 /* format when called as cpio or tar -S */
153#define F_OTAR 5 /* format when called as tar -o */
154#define F_TAR 6 /* format when called as tar */
155#define DEFLT 6 /* default write format from list above */
156
157/*
158 * ford is the archive search order used by get_arc() to determine what kind
159 * of archive we are dealing with. This helps to properly id archive formats
160 * some formats may be subsets of others....
161 */
162int ford[] = {6, 5, 4, 3, 1, 0, -1 };
163
164/* normalise archives */
165int anonarch = 0;
166
167/* extract to standard output */
168int to_stdout = 0;
169
170/*
171 * options()
172 * figure out if we are pax, tar or cpio. Call the appropriate options
173 * parser
174 */
175
176void
177options(int argc, char **argv)
178{
179
180 /*
181 * Are we acting like pax, tar or cpio (based on argv[0])
182 */
183 if ((argv0 = strrchr(argv[0], '/')) != NULL)
184 argv0++;
185 else
186 argv0 = argv[0];
187
188 if (strcmp(NM_TAR, argv0) == 0) {
189 tar_options(argc, argv);
190 return;
191 } else if (strcmp(NM_CPIO, argv0) == 0) {
192 cpio_options(argc, argv);
193 return;
194 }
195 /*
196 * assume pax as the default
197 */
198 argv0 = NM_PAX;
199 pax_options(argc, argv);
200}
201
202/*
203 * pax_options()
204 * look at the user specified flags. set globals as required and check if
205 * the user specified a legal set of flags. If not, complain and exit
206 */
207
208static void
209pax_options(int argc, char **argv)
210{
211 int c;
212 int i;
213 unsigned int flg = 0;
214 unsigned int bflg = 0;
215 char *pt;
216 FSUB tmp;
217
218 /*
219 * process option flags
220 */
221 while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ0"))
222 != -1) {
223 switch (c) {
224 case 'a':
225 /*
226 * append
227 */
228 flg |= AF;
229 break;
230 case 'b':
231 /*
232 * specify blocksize
233 */
234 flg |= BF;
235 if ((wrblksz = (int)str_offt(optarg)) <= 0) {
236 paxwarn(1, "Invalid block size %s", optarg);
237 pax_usage();
238 }
239 break;
240 case 'c':
241 /*
242 * inverse match on patterns
243 */
244 cflag = 1;
245 flg |= CF;
246 break;
247 case 'd':
248 /*
249 * match only dir on extract, not the subtree at dir
250 */
251 dflag = 1;
252 flg |= DF;
253 break;
254 case 'f':
255 /*
256 * filename where the archive is stored
257 */
258 arcname = optarg;
259 flg |= FF;
260 break;
261 case 'i':
262 /*
263 * interactive file rename
264 */
265 iflag = 1;
266 flg |= IF;
267 break;
268 case 'k':
269 /*
270 * do not clobber files that exist
271 */
272 kflag = 1;
273 flg |= KF;
274 break;
275 case 'l':
276 /*
277 * try to link src to dest with copy (-rw)
278 */
279 lflag = 1;
280 flg |= LF;
281 break;
282 case 'n':
283 /*
284 * select first match for a pattern only
285 */
286 nflag = 1;
287 flg |= NF;
288 break;
289 case 'o':
290 /*
291 * pass format specific options
292 */
293 flg |= OF;
294 if (opt_add(optarg) < 0)
295 pax_usage();
296 break;
297 case 'p':
298 /*
299 * specify file characteristic options
300 */
301 for (pt = optarg; *pt != '\0'; ++pt) {
302 switch (*pt) {
303 case 'a':
304 /*
305 * do not preserve access time
306 */
307 patime = 0;
308 break;
309 case 'e':
310 /*
311 * preserve user id, group id, file
312 * mode, access/modification times
313 */
314 pids = 1;
315 pmode = 1;
316 patime = 1;
317 pmtime = 1;
318 break;
319 case 'm':
320 /*
321 * do not preserve modification time
322 */
323 pmtime = 0;
324 break;
325 case 'o':
326 /*
327 * preserve uid/gid
328 */
329 pids = 1;
330 break;
331 case 'p':
332 /*
333 * preserve file mode bits
334 */
335 pmode = 1;
336 break;
337 default:
338 paxwarn(1, "Invalid -p string: %c", *pt);
339 pax_usage();
340 break;
341 }
342 }
343 flg |= PF;
344 break;
345 case 'r':
346 /*
347 * read the archive
348 */
349 flg |= RF;
350 break;
351 case 's':
352 /*
353 * file name substitution name pattern
354 */
355 if (rep_add(optarg) < 0) {
356 pax_usage();
357 break;
358 }
359 flg |= SF;
360 break;
361 case 't':
362 /*
363 * preserve access time on filesystem nodes we read
364 */
365 tflag = 1;
366 flg |= TF;
367 break;
368 case 'u':
369 /*
370 * ignore those older files
371 */
372 uflag = 1;
373 flg |= UF;
374 break;
375 case 'v':
376 /*
377 * verbose operation mode
378 */
379 vflag = 1;
380 flg |= VF;
381 break;
382 case 'w':
383 /*
384 * write an archive
385 */
386 flg |= WF;
387 break;
388 case 'x':
389 /*
390 * specify an archive format on write
391 */
392 tmp.name = optarg;
393 if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
394 sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt)) != NULL) {
395 flg |= XF;
396 break;
397 }
398 paxwarn(1, "Unknown -x format: %s", optarg);
399 (void)fputs("pax: Known -x formats are:", stderr);
400 for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
401 (void)fprintf(stderr, " %s", fsub[i].name);
402 (void)fputs("\n\n", stderr);
403 pax_usage();
404 break;
405 case 'z':
406 /*
407 * use gzip. Non standard option.
408 */
409 gzip_program = GZIP_CMD;
410 break;
411 case 'B':
412 /*
413 * non-standard option on number of bytes written on a
414 * single archive volume.
415 */
416 if ((wrlimit = str_offt(optarg)) <= 0) {
417 paxwarn(1, "Invalid write limit %s", optarg);
418 pax_usage();
419 }
420 if (wrlimit % BLKMULT) {
421 paxwarn(1, "Write limit is not a %d byte multiple",
422 BLKMULT);
423 pax_usage();
424 }
425 flg |= CBF;
426 break;
427 case 'D':
428 /*
429 * On extraction check file inode change time before the
430 * modification of the file name. Non standard option.
431 */
432 Dflag = 1;
433 flg |= CDF;
434 break;
435 case 'E':
436 /*
437 * non-standard limit on read faults
438 * 0 indicates stop after first error, values
439 * indicate a limit, "NONE" try forever
440 */
441 flg |= CEF;
442 if (strcmp(NONE, optarg) == 0)
443 maxflt = -1;
444 else if ((maxflt = atoi(optarg)) < 0) {
445 paxwarn(1, "Error count value must be positive");
446 pax_usage();
447 }
448 break;
449 case 'G':
450 /*
451 * non-standard option for selecting files within an
452 * archive by group (gid or name)
453 */
454 if (grp_add(optarg) < 0) {
455 pax_usage();
456 break;
457 }
458 flg |= CGF;
459 break;
460 case 'H':
461 /*
462 * follow command line symlinks only
463 */
464 Hflag = 1;
465 flg |= CHF;
466 break;
467 case 'L':
468 /*
469 * follow symlinks
470 */
471 Lflag = 1;
472 flg |= CLF;
473 break;
474 case 'O':
475 /*
476 * Force one volume. Non standard option.
477 */
478 force_one_volume = 1;
479 break;
480 case 'P':
481 /*
482 * do NOT follow symlinks (default)
483 */
484 Lflag = 0;
485 flg |= CPF;
486 break;
487 case 'T':
488 /*
489 * non-standard option for selecting files within an
490 * archive by modification time range (lower,upper)
491 */
492 if (trng_add(optarg) < 0) {
493 pax_usage();
494 break;
495 }
496 flg |= CTF;
497 break;
498 case 'U':
499 /*
500 * non-standard option for selecting files within an
501 * archive by user (uid or name)
502 */
503 if (usr_add(optarg) < 0) {
504 pax_usage();
505 break;
506 }
507 flg |= CUF;
508 break;
509 case 'X':
510 /*
511 * do not pass over mount points in the file system
512 */
513 Xflag = 1;
514 flg |= CXF;
515 break;
516 case 'Y':
517 /*
518 * On extraction check file inode change time after the
519 * modification of the file name. Non standard option.
520 */
521 Yflag = 1;
522 flg |= CYF;
523 break;
524 case 'Z':
525 /*
526 * On extraction check modification time after the
527 * modification of the file name. Non standard option.
528 */
529 Zflag = 1;
530 flg |= CZF;
531 break;
532 case '0':
533 /*
534 * Use \0 as pathname terminator.
535 * (For use with the -print0 option of find(1).)
536 */
537 zeroflag = 1;
538 flg |= C0F;
539 break;
540 default:
541 pax_usage();
542 break;
543 }
544 }
545
546 /*
547 * figure out the operation mode of pax read,write,extract,copy,append
548 * or list. check that we have not been given a bogus set of flags
549 * for the operation mode.
550 */
551 if (ISLIST(flg)) {
552 act = LIST;
553 listf = stdout;
554 bflg = flg & BDLIST;
555 } else if (ISEXTRACT(flg)) {
556 act = EXTRACT;
557 bflg = flg & BDEXTR;
558 } else if (ISARCHIVE(flg)) {
559 act = ARCHIVE;
560 bflg = flg & BDARCH;
561 } else if (ISAPPND(flg)) {
562 act = APPND;
563 bflg = flg & BDARCH;
564 } else if (ISCOPY(flg)) {
565 act = COPY;
566 bflg = flg & BDCOPY;
567 } else
568 pax_usage();
569 if (bflg) {
570 printflg(flg);
571 pax_usage();
572 }
573
574 /*
575 * if we are writing (ARCHIVE) we use the default format if the user
576 * did not specify a format. when we write during an APPEND, we will
577 * adopt the format of the existing archive if none was supplied.
578 */
579 if (!(flg & XF) && (act == ARCHIVE))
580 frmt = &(fsub[DEFLT]);
581
582 /*
583 * process the args as they are interpreted by the operation mode
584 */
585 switch (act) {
586 case LIST:
587 case EXTRACT:
588 for (; optind < argc; optind++)
589 if (pat_add(argv[optind], NULL) < 0)
590 pax_usage();
591 break;
592 case COPY:
593 if (optind >= argc) {
594 paxwarn(0, "Destination directory was not supplied");
595 pax_usage();
596 }
597 --argc;
598 dirptr = argv[argc];
599 /* FALL THROUGH */
600 case ARCHIVE:
601 case APPND:
602 for (; optind < argc; optind++)
603 if (ftree_add(argv[optind], 0) < 0)
604 pax_usage();
605 /*
606 * no read errors allowed on updates/append operation!
607 */
608 maxflt = 0;
609 break;
610 }
611}
612
613
614/*
615 * tar_options()
616 * look at the user specified flags. set globals as required and check if
617 * the user specified a legal set of flags. If not, complain and exit
618 */
619
620static void
621tar_options(int argc, char **argv)
622{
623 int c;
624 int fstdin = 0;
625 int Oflag = 0;
626 int nincfiles = 0;
627 int incfiles_max = 0;
628 struct incfile {
629 char *file;
630 char *dir;
631 };
632 struct incfile *incfiles = NULL;
633
634 /*
635 * Set default values.
636 */
637 rmleadslash = 1;
638
639 /*
640 * process option flags
641 */
642 while ((c = getoldopt(argc, argv,
643 "b:cef:hmopqruts:vwxzBC:HI:LM:OPRSXZ014578")) != -1) {
644 switch (c) {
645 case 'b':
646 /*
647 * specify blocksize in 512-byte blocks
648 */
649 if ((wrblksz = (int)str_offt(optarg)) <= 0) {
650 paxwarn(1, "Invalid block size %s", optarg);
651 tar_usage();
652 }
653 wrblksz *= 512; /* XXX - check for int oflow */
654 break;
655 case 'c':
656 /*
657 * create an archive
658 */
659 act = ARCHIVE;
660 break;
661 case 'e':
662 /*
663 * stop after first error
664 */
665 maxflt = 0;
666 break;
667 case 'f':
668 /*
669 * filename where the archive is stored
670 */
671 if ((optarg[0] == '-') && (optarg[1]== '\0')) {
672 /*
673 * treat a - as stdin
674 */
675 fstdin = 1;
676 arcname = NULL;
677 break;
678 }
679 fstdin = 0;
680 arcname = optarg;
681 break;
682 case 'h':
683 /*
684 * follow symlinks
685 */
686 Lflag = 1;
687 break;
688 case 'm':
689 /*
690 * do not preserve modification time
691 */
692 pmtime = 0;
693 break;
694 case 'O':
695 Oflag = 1;
696 to_stdout = 2;
697 break;
698 case 'o':
699 Oflag = 2;
700 break;
701 case 'p':
702 /*
703 * preserve uid/gid and file mode, regardless of umask
704 */
705 pmode = 1;
706 pids = 1;
707 break;
708 case 'q':
709 /*
710 * select first match for a pattern only
711 */
712 nflag = 1;
713 break;
714 case 'r':
715 case 'u':
716 /*
717 * append to the archive
718 */
719 act = APPND;
720 break;
721 case 'R':
722 Oflag = 3;
723 anonarch = ANON_INODES | ANON_HARDLINKS;
724 break;
725 case 'S':
726 Oflag = 4;
727 anonarch = ANON_INODES | ANON_HARDLINKS;
728 break;
729 case 's':
730 /*
731 * file name substitution name pattern
732 */
733 if (rep_add(optarg) < 0) {
734 tar_usage();
735 break;
736 }
737 break;
738 case 't':
739 /*
740 * list contents of the tape
741 */
742 act = LIST;
743 break;
744 case 'v':
745 /*
746 * verbose operation mode
747 */
748 vflag++;
749 break;
750 case 'w':
751 /*
752 * interactive file rename
753 */
754 iflag = 1;
755 break;
756 case 'x':
757 /*
758 * extract an archive, preserving mode,
759 * and mtime if possible.
760 */
761 act = EXTRACT;
762 pmtime = 1;
763 break;
764 case 'z':
765 /*
766 * use gzip. Non standard option.
767 */
768 gzip_program = GZIP_CMD;
769 break;
770 case 'B':
771 /*
772 * Nothing to do here, this is pax default
773 */
774 break;
775 case 'C':
776 chdname = optarg;
777 break;
778 case 'H':
779 /*
780 * follow command line symlinks only
781 */
782 Hflag = 1;
783 break;
784 case 'I':
785 if (++nincfiles > incfiles_max) {
786 incfiles_max = nincfiles + 3;
787 incfiles = realloc(incfiles,
788 sizeof(*incfiles) * incfiles_max);
789 if (incfiles == NULL) {
790 paxwarn(0, "Unable to allocate space "
791 "for option list");
792 exit(1);
793 }
794 }
795 incfiles[nincfiles - 1].file = optarg;
796 incfiles[nincfiles - 1].dir = chdname;
797 break;
798 case 'L':
799 /*
800 * follow symlinks
801 */
802 Lflag = 1;
803 break;
804 case 'M':
805 process_M(optarg, tar_usage);
806 break;
807 case 'P':
808 /*
809 * do not remove leading '/' from pathnames
810 */
811 rmleadslash = 0;
812 break;
813 case 'X':
814 /*
815 * do not pass over mount points in the file system
816 */
817 Xflag = 1;
818 break;
819 case 'Z':
820 /*
821 * use compress.
822 */
823 gzip_program = COMPRESS_CMD;
824 break;
825 case '0':
826 arcname = DEV_0;
827 break;
828 case '1':
829 arcname = DEV_1;
830 break;
831 case '4':
832 arcname = DEV_4;
833 break;
834 case '5':
835 arcname = DEV_5;
836 break;
837 case '7':
838 arcname = DEV_7;
839 break;
840 case '8':
841 arcname = DEV_8;
842 break;
843 default:
844 tar_usage();
845 break;
846 }
847 }
848 argc -= optind;
849 argv += optind;
850
851 /* Traditional tar behaviour (pax uses stderr unless in list mode) */
852 if (fstdin == 1 && act == ARCHIVE)
853 listf = stderr;
854 else
855 listf = stdout;
856
857 /* Traditional tar behaviour (pax wants to read file list from stdin) */
858 if ((act == ARCHIVE || act == APPND) && argc == 0 && nincfiles == 0)
859 exit(0);
860
861 /*
862 * process the args as they are interpreted by the operation mode
863 */
864 switch (act) {
865 case EXTRACT:
866 if (to_stdout == 2)
867 to_stdout = 1;
868 case LIST:
869 default:
870 {
871 int sawpat = 0;
872 char *file, *dir = NULL;
873
874 while (nincfiles || *argv != NULL) {
875 /*
876 * If we queued up any include files,
877 * pull them in now. Otherwise, check
878 * for -I and -C positional flags.
879 * Anything else must be a file to
880 * extract.
881 */
882 if (nincfiles) {
883 file = incfiles->file;
884 dir = incfiles->dir;
885 incfiles++;
886 nincfiles--;
887 } else if (strcmp(*argv, "-I") == 0) {
888 if (*++argv == NULL)
889 break;
890 file = *argv++;
891 dir = chdname;
892 } else
893 file = NULL;
894 if (file != NULL) {
895 FILE *fp;
896 char *str;
897
898 if (strcmp(file, "-") == 0)
899 fp = stdin;
900 else if ((fp = fopen(file, "r")) == NULL) {
901 paxwarn(1, "Unable to open file '%s' for read", file);
902 tar_usage();
903 }
904 while ((str = getline(fp)) != NULL) {
905 if (pat_add(str, dir) < 0)
906 tar_usage();
907 sawpat = 1;
908 }
909 if (strcmp(file, "-") != 0)
910 fclose(fp);
911 if (getline_error) {
912 paxwarn(1, "Problem with file '%s'", file);
913 tar_usage();
914 }
915 } else if (strcmp(*argv, "-C") == 0) {
916 if (*++argv == NULL)
917 break;
918 chdname = *argv++;
919 } else if (pat_add(*argv++, chdname) < 0)
920 tar_usage();
921 else
922 sawpat = 1;
923 }
924 /*
925 * if patterns were added, we are doing chdir()
926 * on a file-by-file basis, else, just one
927 * global chdir (if any) after opening input.
928 */
929 if (sawpat > 0)
930 chdname = NULL;
931 }
932 break;
933 case ARCHIVE:
934 case APPND:
935 switch(Oflag) {
936 case 0:
937 frmt = &(fsub[F_TAR]);
938 break;
939 case 1:
940 frmt = &(fsub[F_OTAR]);
941 break;
942 case 2:
943 frmt = &(fsub[F_OTAR]);
944 if (opt_add("write_opt=nodir") < 0)
945 tar_usage();
946 break;
947 case 3:
948 frmt = &(fsub[F_NCPIO]);
949 break;
950 case 4:
951 frmt = &(fsub[F_CPIO]);
952 break;
953 default:
954 tar_usage();
955 break;
956 }
957
958 if (chdname != NULL) { /* initial chdir() */
959 if (ftree_add(chdname, 1) < 0)
960 tar_usage();
961 }
962
963 while (nincfiles || *argv != NULL) {
964 char *file, *dir = NULL;
965
966 /*
967 * If we queued up any include files, pull them in
968 * now. Otherwise, check for -I and -C positional
969 * flags. Anything else must be a file to include
970 * in the archive.
971 */
972 if (nincfiles) {
973 file = incfiles->file;
974 dir = incfiles->dir;
975 incfiles++;
976 nincfiles--;
977 } else if (strcmp(*argv, "-I") == 0) {
978 if (*++argv == NULL)
979 break;
980 file = *argv++;
981 dir = NULL;
982 } else
983 file = NULL;
984 if (file != NULL) {
985 FILE *fp;
986 char *str;
987
988 /* Set directory if needed */
989 if (dir) {
990 if (ftree_add(dir, 1) < 0)
991 tar_usage();
992 }
993
994 if (strcmp(file, "-") == 0)
995 fp = stdin;
996 else if ((fp = fopen(file, "r")) == NULL) {
997 paxwarn(1, "Unable to open file '%s' for read", file);
998 tar_usage();
999 }
1000 while ((str = getline(fp)) != NULL) {
1001 if (ftree_add(str, 0) < 0)
1002 tar_usage();
1003 }
1004 if (strcmp(file, "-") != 0)
1005 fclose(fp);
1006 if (getline_error) {
1007 paxwarn(1, "Problem with file '%s'",
1008 file);
1009 tar_usage();
1010 }
1011 } else if (strcmp(*argv, "-C") == 0) {
1012 if (*++argv == NULL)
1013 break;
1014 if (ftree_add(*argv++, 1) < 0)
1015 tar_usage();
1016 } else if (ftree_add(*argv++, 0) < 0)
1017 tar_usage();
1018 }
1019 /*
1020 * no read errors allowed on updates/append operation!
1021 */
1022 maxflt = 0;
1023 break;
1024 }
1025 if (to_stdout != 1)
1026 to_stdout = 0;
1027 if (!fstdin && ((arcname == NULL) || (*arcname == '\0'))) {
1028 arcname = getenv("TAPE");
1029#ifdef _PATH_DEFTAPE
1030 if ((arcname == NULL) || (*arcname == '\0'))
1031 arcname = _PATH_DEFTAPE;
1032#endif
1033 }
1034}
1035
1036int
1037mkpath(char *path)
1038{
1039 struct stat sb;
1040 char *slash;
1041 int done = 0;
1042
1043 slash = path;
1044
1045 while (!done) {
1046 slash += strspn(slash, "/");
1047 slash += strcspn(slash, "/");
1048
1049 done = (*slash == '\0');
1050 *slash = '\0';
1051
1052 if (stat(path, &sb)) {
1053 if (errno != ENOENT || mkdir(path, 0777)) {
1054 paxwarn(1, "%s", path);
1055 return (-1);
1056 }
1057 } else if (!S_ISDIR(sb.st_mode)) {
1058 syswarn(1, ENOTDIR, "%s", path);
1059 return (-1);
1060 }
1061
1062 if (!done)
1063 *slash = '/';
1064 }
1065
1066 return (0);
1067}
1068/*
1069 * cpio_options()
1070 * look at the user specified flags. set globals as required and check if
1071 * the user specified a legal set of flags. If not, complain and exit
1072 */
1073
1074static void
1075cpio_options(int argc, char **argv)
1076{
1077 int c, i;
1078 char *str;
1079 FSUB tmp;
1080 FILE *fp;
1081
1082 kflag = 1;
1083 pids = 1;
1084 pmode = 1;
1085 pmtime = 0;
1086 arcname = NULL;
1087 dflag = 1;
1088 act = -1;
1089 nodirs = 1;
1090 while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LM:O:SZ6")) != -1)
1091 switch (c) {
1092 case 'a':
1093 /*
1094 * preserve access time on files read
1095 */
1096 tflag = 1;
1097 break;
1098 case 'b':
1099 /*
1100 * swap bytes and half-words when reading data
1101 */
1102 break;
1103 case 'c':
1104 /*
1105 * ASCII cpio header
1106 */
1107 frmt = &(fsub[F_ACPIO]);
1108 break;
1109 case 'd':
1110 /*
1111 * create directories as needed
1112 */
1113 nodirs = 0;
1114 break;
1115 case 'f':
1116 /*
1117 * invert meaning of pattern list
1118 */
1119 cflag = 1;
1120 break;
1121 case 'i':
1122 /*
1123 * restore an archive
1124 */
1125 act = EXTRACT;
1126 break;
1127 case 'k':
1128 break;
1129 case 'l':
1130 /*
1131 * use links instead of copies when possible
1132 */
1133 lflag = 1;
1134 break;
1135 case 'm':
1136 /*
1137 * preserve modification time
1138 */
1139 pmtime = 1;
1140 break;
1141 case 'o':
1142 /*
1143 * create an archive
1144 */
1145 act = ARCHIVE;
1146 frmt = &(fsub[F_CPIO]);
1147 break;
1148 case 'p':
1149 /*
1150 * copy-pass mode
1151 */
1152 act = COPY;
1153 break;
1154 case 'r':
1155 /*
1156 * interactively rename files
1157 */
1158 iflag = 1;
1159 break;
1160 case 's':
1161 /*
1162 * swap bytes after reading data
1163 */
1164 break;
1165 case 't':
1166 /*
1167 * list contents of archive
1168 */
1169 act = LIST;
1170 listf = stdout;
1171 break;
1172 case 'u':
1173 /*
1174 * replace newer files
1175 */
1176 kflag = 0;
1177 break;
1178 case 'v':
1179 /*
1180 * verbose operation mode
1181 */
1182 vflag = 1;
1183 break;
1184 case 'z':
1185 /*
1186 * use gzip. Non standard option.
1187 */
1188 gzip_program = GZIP_CMD;
1189 break;
1190 case 'A':
1191 /*
1192 * append mode
1193 */
1194 act = APPND;
1195 break;
1196 case 'B':
1197 /*
1198 * Use 5120 byte block size
1199 */
1200 wrblksz = 5120;
1201 break;
1202 case 'C':
1203 /*
1204 * set block size in bytes
1205 */
1206 wrblksz = atoi(optarg);
1207 break;
1208 case 'E':
1209 /*
1210 * file with patterns to extract or list
1211 */
1212 if ((fp = fopen(optarg, "r")) == NULL) {
1213 paxwarn(1, "Unable to open file '%s' for read", optarg);
1214 cpio_usage();
1215 }
1216 while ((str = getline(fp)) != NULL) {
1217 pat_add(str, NULL);
1218 }
1219 fclose(fp);
1220 if (getline_error) {
1221 paxwarn(1, "Problem with file '%s'", optarg);
1222 cpio_usage();
1223 }
1224 break;
1225 case 'F':
1226 case 'I':
1227 case 'O':
1228 /*
1229 * filename where the archive is stored
1230 */
1231 if ((optarg[0] == '-') && (optarg[1]== '\0')) {
1232 /*
1233 * treat a - as stdin
1234 */
1235 arcname = NULL;
1236 break;
1237 }
1238 arcname = optarg;
1239 break;
1240 case 'H':
1241 /*
1242 * specify an archive format on write
1243 */
1244 if (!strcmp(optarg, "bin")) {
1245 tmp.name = "bcpio";
1246 } else if (!strcmp(optarg, "crc")) {
1247 tmp.name = "sv4crc";
1248 } else if (!strcmp(optarg, "newc")) {
1249 tmp.name = "sv4cpio";
1250 } else if (!strcmp(optarg, "odc")) {
1251 tmp.name = "cpio";
1252 } else {
1253 tmp.name = optarg;
1254 }
1255 if ((frmt = (FSUB *)bsearch((void *)&tmp, (void *)fsub,
1256 sizeof(fsub)/sizeof(FSUB), sizeof(FSUB), c_frmt)) != NULL)
1257 break;
1258 paxwarn(1, "Unknown -H format: %s", optarg);
1259 (void)fputs("cpio: Known -H formats are:", stderr);
1260 for (i = 0; i < (sizeof(fsub)/sizeof(FSUB)); ++i)
1261 (void)fprintf(stderr, " %s", fsub[i].name);
1262 (void)fputs("\n\n", stderr);
1263 cpio_usage();
1264 break;
1265 case 'L':
1266 /*
1267 * follow symbolic links
1268 */
1269 Lflag = 1;
1270 break;
1271 case 'M':
1272 process_M(optarg, cpio_usage);
1273 break;
1274 case 'S':
1275 /*
1276 * swap halfwords after reading data
1277 */
1278 break;
1279 case 'Z':
1280 /*
1281 * use compress. Non standard option.
1282 */
1283 gzip_program = COMPRESS_CMD;
1284 break;
1285 case '6':
1286 /*
1287 * process Version 6 cpio format
1288 */
1289 frmt = &(fsub[F_OCPIO]);
1290 break;
1291 case '?':
1292 default:
1293 cpio_usage();
1294 break;
1295 }
1296 argc -= optind;
1297 argv += optind;
1298
1299 /*
1300 * process the args as they are interpreted by the operation mode
1301 */
1302 switch (act) {
1303 case LIST:
1304 case EXTRACT:
1305 while (*argv != NULL)
1306 if (pat_add(*argv++, NULL) < 0)
1307 cpio_usage();
1308 break;
1309 case COPY:
1310 if (*argv == NULL) {
1311 paxwarn(0, "Destination directory was not supplied");
1312 cpio_usage();
1313 }
1314 dirptr = *argv;
1315 if (mkpath(dirptr) < 0)
1316 cpio_usage();
1317 --argc;
1318 ++argv;
1319 /* FALL THROUGH */
1320 case ARCHIVE:
1321 case APPND:
1322 if (*argv != NULL)
1323 cpio_usage();
1324 /*
1325 * no read errors allowed on updates/append operation!
1326 */
1327 maxflt = 0;
1328 while ((str = getline(stdin)) != NULL) {
1329 ftree_add(str, 0);
1330 }
1331 if (getline_error) {
1332 paxwarn(1, "Problem while reading stdin");
1333 cpio_usage();
1334 }
1335 break;
1336 default:
1337 cpio_usage();
1338 break;
1339 }
1340}
1341
1342/*
1343 * printflg()
1344 * print out those invalid flag sets found to the user
1345 */
1346
1347static void
1348printflg(unsigned int flg)
1349{
1350 int nxt;
1351 int pos = 0;
1352
1353 (void)fprintf(stderr,"%s: Invalid combination of options:", argv0);
1354 while ((nxt = ffs(flg)) != 0) {
1355 flg = flg >> nxt;
1356 pos += nxt;
1357 (void)fprintf(stderr, " -%c", flgch[pos-1]);
1358 }
1359 (void)putc('\n', stderr);
1360}
1361
1362/*
1363 * c_frmt()
1364 * comparison routine used by bsearch to find the format specified
1365 * by the user
1366 */
1367
1368static int
1369c_frmt(const void *a, const void *b)
1370{
1371 return(strcmp(((FSUB *)a)->name, ((FSUB *)b)->name));
1372}
1373
1374/*
1375 * opt_next()
1376 * called by format specific options routines to get each format specific
1377 * flag and value specified with -o
1378 * Return:
1379 * pointer to next OPLIST entry or NULL (end of list).
1380 */
1381
1382OPLIST *
1383opt_next(void)
1384{
1385 OPLIST *opt;
1386
1387 if ((opt = ophead) != NULL)
1388 ophead = ophead->fow;
1389 return(opt);
1390}
1391
1392/*
1393 * bad_opt()
1394 * generic routine used to complain about a format specific options
1395 * when the format does not support options.
1396 */
1397
1398int
1399bad_opt(void)
1400{
1401 OPLIST *opt;
1402
1403 if (ophead == NULL)
1404 return(0);
1405 /*
1406 * print all we were given
1407 */
1408 paxwarn(1,"These format options are not supported");
1409 while ((opt = opt_next()) != NULL)
1410 (void)fprintf(stderr, "\t%s = %s\n", opt->name, opt->value);
1411 pax_usage();
1412 return(0);
1413}
1414
1415/*
1416 * opt_add()
1417 * breaks the value supplied to -o into a option name and value. options
1418 * are given to -o in the form -o name-value,name=value
1419 * multiple -o may be specified.
1420 * Return:
1421 * 0 if format in name=value format, -1 if -o is passed junk
1422 */
1423
1424int
1425opt_add(const char *str)
1426{
1427 OPLIST *opt;
1428 char *frpt;
1429 char *pt;
1430 char *endpt;
1431 char *dstr;
1432
1433 if ((str == NULL) || (*str == '\0')) {
1434 paxwarn(0, "Invalid option name");
1435 return(-1);
1436 }
1437 if ((dstr = strdup(str)) == NULL) {
1438 paxwarn(0, "Unable to allocate space for option list");
1439 return(-1);
1440 }
1441 frpt = endpt = dstr;
1442
1443 /*
1444 * break into name and values pieces and stuff each one into a
1445 * OPLIST structure. When we know the format, the format specific
1446 * option function will go through this list
1447 */
1448 while ((frpt != NULL) && (*frpt != '\0')) {
1449 if ((endpt = strchr(frpt, ',')) != NULL)
1450 *endpt = '\0';
1451 if ((pt = strchr(frpt, '=')) == NULL) {
1452 paxwarn(0, "Invalid options format");
1453 free(dstr);
1454 return(-1);
1455 }
1456 if ((opt = (OPLIST *)malloc(sizeof(OPLIST))) == NULL) {
1457 paxwarn(0, "Unable to allocate space for option list");
1458 free(dstr);
1459 return(-1);
1460 }
1461 *pt++ = '\0';
1462 opt->name = frpt;
1463 opt->value = pt;
1464 opt->fow = NULL;
1465 if (endpt != NULL)
1466 frpt = endpt + 1;
1467 else
1468 frpt = NULL;
1469 if (ophead == NULL) {
1470 optail = ophead = opt;
1471 continue;
1472 }
1473 optail->fow = opt;
1474 optail = opt;
1475 }
1476 return(0);
1477}
1478
1479/*
1480 * str_offt()
1481 * Convert an expression of the following forms to an off_t > 0.
1482 * 1) A positive decimal number.
1483 * 2) A positive decimal number followed by a b (mult by 512).
1484 * 3) A positive decimal number followed by a k (mult by 1024).
1485 * 4) A positive decimal number followed by a m (mult by 512).
1486 * 5) A positive decimal number followed by a w (mult by sizeof int)
1487 * 6) Two or more positive decimal numbers (with/without k,b or w).
1488 * separated by x (also * for backwards compatibility), specifying
1489 * the product of the indicated values.
1490 * Return:
1491 * 0 for an error, a positive value o.w.
1492 */
1493
1494static off_t
1495str_offt(char *val)
1496{
1497 char *expr;
1498 off_t num, t;
1499
1500# ifdef LONG_OFF_T
1501 num = strtol(val, &expr, 0);
1502 if ((num == LONG_MAX) || (num <= 0) || (expr == val))
1503# else
1504 num = strtoll(val, &expr, 0);
1505 if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
1506# endif
1507 return(0);
1508
1509 switch (*expr) {
1510 case 'b':
1511 t = num;
1512 num *= 512;
1513 if (t > num)
1514 return(0);
1515 ++expr;
1516 break;
1517 case 'k':
1518 t = num;
1519 num *= 1024;
1520 if (t > num)
1521 return(0);
1522 ++expr;
1523 break;
1524 case 'm':
1525 t = num;
1526 num *= 1048576;
1527 if (t > num)
1528 return(0);
1529 ++expr;
1530 break;
1531 case 'w':
1532 t = num;
1533 num *= sizeof(int);
1534 if (t > num)
1535 return(0);
1536 ++expr;
1537 break;
1538 }
1539
1540 switch (*expr) {
1541 case '\0':
1542 break;
1543 case '*':
1544 case 'x':
1545 t = num;
1546 num *= str_offt(expr + 1);
1547 if (t > num)
1548 return(0);
1549 break;
1550 default:
1551 return(0);
1552 }
1553 return(num);
1554}
1555
1556char *
1557getline(FILE *f)
1558{
1559 char *name, *temp;
1560 size_t len;
1561
1562 name = fgetln(f, &len);
1563 if (!name) {
1564 getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
1565 return(0);
1566 }
1567 if (name[len-1] != '\n')
1568 len++;
1569 temp = malloc(len);
1570 if (!temp) {
1571 getline_error = GETLINE_OUT_OF_MEM;
1572 return(0);
1573 }
1574 memcpy(temp, name, len-1);
1575 temp[len-1] = 0;
1576 return(temp);
1577}
1578
1579/*
1580 * no_op()
1581 * for those option functions where the archive format has nothing to do.
1582 * Return:
1583 * 0
1584 */
1585
1586static int
1587no_op(void)
1588{
1589 return(0);
1590}
1591
1592/*
1593 * pax_usage()
1594 * print the usage summary to the user
1595 */
1596
1597void
1598pax_usage(void)
1599{
1600 (void)fputs(
1601 "usage: pax [-0cdOnRSvz] [-E limit] [-f archive] [-G group] [-s replstr]\n"
1602 "\t [-T [from_date][,to_date][/[c][m]]] [-U user] [pattern ...]\n"
1603 " pax -r [-0cDdikOnuvzYZz] [-E limit] [-f archive] [-G group]\n"
1604 "\t [-o options] [-p string] [-s replstr] [-T [from_date][,to_date]]\n"
1605 "\t [-U user] [pattern ...]\n"
1606 " pax -w [-0adHiLOPtuvXz] [-B bytes] [-b blocksize] [-f archive]\n"
1607 "\t [-G group] [-o options] [-s replstr]\n"
1608 "\t [-T [from_date][,to_date][/[c][m]]] [-U user] [-x format] [file ...]\n"
1609 " pax -r -w [-0DdHikLlnOPtuvXYZ] [-G group] [-p string] [-s replstr]\n"
1610 "\t [-T [from_date][,to_date][/[c][m]]] [-U user] [file ...] directory\n",
1611 stderr);
1612 exit(1);
1613}
1614
1615/*
1616 * tar_usage()
1617 * print the usage summary to the user
1618 */
1619
1620void
1621tar_usage(void)
1622{
1623 (void)fputs(
1624 "usage: tar {crtux}[014578befHhLmOoPpqsvwXZz]\n"
1625 "\t [blocking-factor | archive | replstr] [-C directory] [-I file]\n"
1626 "\t [file ...]\n"
1627 " tar {-crtux} [-014578eHhLmOoPpqvwXZz] [-b blocking-factor] [-M value]\n"
1628 "\t [-C directory] [-f archive] [-I file] [-s replstr] [file ...]\n",
1629 stderr);
1630 exit(1);
1631}
1632
1633/*
1634 * cpio_usage()
1635 * print the usage summary to the user
1636 */
1637
1638void
1639cpio_usage(void)
1640{
1641 (void)fputs("usage: cpio -o [-aABcLvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);
1642 (void)fputs(" [-M flag] [-F archive] <name-list [>archive]\n", stderr);
1643 (void)fputs(" cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr);
1644 (void)fputs(" [-I archive] [-F archive] [pattern...] [<archive]\n", stderr);
1645 (void)fputs(" cpio -p [-adlLmuvV] destination-directory <name-list\n", stderr);
1646 exit(1);
1647}
1648
1649void
1650anonarch_init(void)
1651{
1652 if (anonarch & ANON_VERBOSE) {
1653 anonarch &= ~ANON_VERBOSE;
1654 paxwarn(0, "debug: -M 0x%08X", anonarch);
1655 }
1656}
1657
1658static void
1659process_M(const char *arg, void (*call_usage)(void))
1660{
1661 int j, k = 0;
1662
1663 if ((arg[0] >= '0') && (arg[0] <= '9')) {
1664#ifdef __OpenBSD__
1665 const char *s;
1666 int64_t i = strtonum(arg, 0,
1667 ANON_MAXVAL, &s);
1668 if (s)
1669 errx(1, "%s M value: %s", s,
1670 arg);
1671#else
1672 char *ep;
1673 long long i = strtoll(arg, &ep, 0);
1674 if ((ep == arg) || (*ep != '\0') ||
1675 (i < 0) || (i > ANON_MAXVAL))
1676 errx(1, "impossible M value:"
1677 " %s", arg);
1678#endif
1679 anonarch = i;
1680 return;
1681 }
1682
1683 if (!strncmp(arg, "no-", 3)) {
1684 j = 0;
1685 arg += 3;
1686 } else
1687 j = 1;
1688 if (!strncmp(arg, "uid", 3) ||
1689 !strncmp(arg, "gid", 3)) {
1690 k = ANON_UIDGID;
1691 } else if (!strncmp(arg, "ino", 3)) {
1692 k = ANON_INODES;
1693 } else if (!strncmp(arg, "mtim", 4)) {
1694 k = ANON_MTIME;
1695 } else if (!strncmp(arg, "link", 4)) {
1696 k = ANON_HARDLINKS;
1697 } else if (!strncmp(arg, "norm", 4)) {
1698 k = ANON_UIDGID | ANON_INODES
1699 | ANON_MTIME | ANON_HARDLINKS;
1700 } else if (!strncmp(arg, "root", 4)) {
1701 k = ANON_UIDGID | ANON_INODES;
1702 } else if (!strncmp(arg, "dist", 4)) {
1703 k = ANON_UIDGID | ANON_INODES
1704 | ANON_HARDLINKS;
1705 } else if (!strncmp(arg, "set", 3)) {
1706 k = ANON_INODES | ANON_HARDLINKS;
1707 } else if (!strncmp(arg, "v", 1)) {
1708 k = ANON_VERBOSE;
1709 } else if (!strncmp(arg, "debug", 5)) {
1710 k = ANON_DEBUG;
1711 } else
1712 call_usage();
1713 if (j)
1714 anonarch |= k;
1715 else
1716 anonarch &= ~k;
1717}
Note: See TracBrowser for help on using the repository browser.