pax.c (76286) | pax.c (76351) |
---|---|
1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 32 unchanged lines hidden (view full) --- 41 The Regents of the University of California. All rights reserved.\n"; 42#endif /* not lint */ 43 44#ifndef lint 45#if 0 46static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; 47#endif 48static const char rcsid[] = | 1/*- 2 * Copyright (c) 1992 Keith Muller. 3 * Copyright (c) 1992, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * Keith Muller of the University of California, San Diego. 8 * --- 32 unchanged lines hidden (view full) --- 41 The Regents of the University of California. All rights reserved.\n"; 42#endif /* not lint */ 43 44#ifndef lint 45#if 0 46static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; 47#endif 48static const char rcsid[] = |
49 "$FreeBSD: head/bin/pax/pax.c 76286 2001-05-05 01:10:13Z kris $"; | 49 "$FreeBSD: head/bin/pax/pax.c 76351 2001-05-08 06:19:06Z kris $"; |
50#endif /* not lint */ 51 52#include <sys/types.h> 53#include <sys/stat.h> 54#include <sys/time.h> 55#include <sys/resource.h> 56#include <err.h> 57#include <errno.h> | 50#endif /* not lint */ 51 52#include <sys/types.h> 53#include <sys/stat.h> 54#include <sys/time.h> 55#include <sys/resource.h> 56#include <err.h> 57#include <errno.h> |
58#include <fcntl.h> |
|
58#include <locale.h> 59#include <paths.h> 60#include <signal.h> 61#include <stdio.h> 62#include <stdlib.h> 63#include <unistd.h> 64#include "pax.h" 65#include "extern.h" --- 4 unchanged lines hidden (view full) --- 70 */ 71 72/* 73 * Variables that can be accessed by any routine within pax 74 */ 75int act = DEFOP; /* read/write/append/copy */ 76FSUB *frmt = NULL; /* archive format type */ 77int cflag; /* match all EXCEPT pattern/file */ | 59#include <locale.h> 60#include <paths.h> 61#include <signal.h> 62#include <stdio.h> 63#include <stdlib.h> 64#include <unistd.h> 65#include "pax.h" 66#include "extern.h" --- 4 unchanged lines hidden (view full) --- 71 */ 72 73/* 74 * Variables that can be accessed by any routine within pax 75 */ 76int act = DEFOP; /* read/write/append/copy */ 77FSUB *frmt = NULL; /* archive format type */ 78int cflag; /* match all EXCEPT pattern/file */ |
79int cwdfd; /* starting cwd */ |
|
78int dflag; /* directory member match only */ 79int iflag; /* interactive file/archive rename */ 80int kflag; /* do not overwrite existing files */ 81int lflag; /* use hard links when possible */ 82int nflag; /* select first archive member match */ 83int tflag; /* restore access time after read */ 84int uflag; /* ignore older modification time files */ 85int vflag; /* produce verbose output */ 86int Dflag; /* same as uflag except inode change time */ 87int Hflag; /* follow command line symlinks (write only) */ 88int Lflag; /* follow symlinks when writing */ 89int Xflag; /* archive files with same device id only */ 90int Yflag; /* same as Dflg except after name mode */ 91int Zflag; /* same as uflg except after name mode */ 92int vfpart; /* is partial verbose output in progress */ 93int patime = 1; /* preserve file access time */ 94int pmtime = 1; /* preserve file modification times */ | 80int dflag; /* directory member match only */ 81int iflag; /* interactive file/archive rename */ 82int kflag; /* do not overwrite existing files */ 83int lflag; /* use hard links when possible */ 84int nflag; /* select first archive member match */ 85int tflag; /* restore access time after read */ 86int uflag; /* ignore older modification time files */ 87int vflag; /* produce verbose output */ 88int Dflag; /* same as uflag except inode change time */ 89int Hflag; /* follow command line symlinks (write only) */ 90int Lflag; /* follow symlinks when writing */ 91int Xflag; /* archive files with same device id only */ 92int Yflag; /* same as Dflg except after name mode */ 93int Zflag; /* same as uflg except after name mode */ 94int vfpart; /* is partial verbose output in progress */ 95int patime = 1; /* preserve file access time */ 96int pmtime = 1; /* preserve file modification times */ |
97int nodirs; /* do not create directories as needed */ |
|
95int pmode; /* preserve file mode bits */ 96int pids; /* preserve file uid/gid */ | 98int pmode; /* preserve file mode bits */ 99int pids; /* preserve file uid/gid */ |
100int rmleadslash = 0; /* remove leading '/' from pathnames */ |
|
97int exit_val; /* exit value */ 98int docrc; /* check/create file crc */ 99char *dirptr; /* destination dir in a copy */ 100char *argv0; /* root of argv[0] */ | 101int exit_val; /* exit value */ 102int docrc; /* check/create file crc */ 103char *dirptr; /* destination dir in a copy */ 104char *argv0; /* root of argv[0] */ |
105sigset_t s_mask; /* signal mask for cleanup critical sect */ 106FILE *listf = stderr; /* file pointer to print file list to */ |
|
101char *tempfile; /* tempfile to use for mkstemp(3) */ 102char *tempbase; /* basename of tempfile to use for mkstemp(3) */ | 107char *tempfile; /* tempfile to use for mkstemp(3) */ 108char *tempbase; /* basename of tempfile to use for mkstemp(3) */ |
103sigset_t s_mask; /* signal mask for cleanup critical sect */ | |
104 105/* 106 * PAX - Portable Archive Interchange 107 * 108 * A utility to read, write, and write lists of the members of archive 109 * files and copy directory hierarchies. A variety of archive formats 110 * are supported (some are described in POSIX 1003.1 10.1): 111 * --- 119 unchanged lines hidden (view full) --- 231 int argc; 232 char **argv; 233#endif 234{ 235 char *tmpdir; 236 size_t tdlen; 237 238 (void) setlocale(LC_ALL, ""); | 109 110/* 111 * PAX - Portable Archive Interchange 112 * 113 * A utility to read, write, and write lists of the members of archive 114 * files and copy directory hierarchies. A variety of archive formats 115 * are supported (some are described in POSIX 1003.1 10.1): 116 * --- 119 unchanged lines hidden (view full) --- 236 int argc; 237 char **argv; 238#endif 239{ 240 char *tmpdir; 241 size_t tdlen; 242 243 (void) setlocale(LC_ALL, ""); |
244 /* 245 * Keep a reference to cwd, so we can always come back home. 246 */ 247 cwdfd = open(".", O_RDONLY); 248 if (cwdfd < 0) { 249 syswarn(0, errno, "Can't open current working directory."); 250 return(exit_val); 251 } |
|
239 240 /* 241 * Where should we put temporary files? 242 */ 243 if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') 244 tmpdir = _PATH_TMP; 245 tdlen = strlen(tmpdir); 246 while(tdlen > 0 && tmpdir[tdlen - 1] == '/') --- 137 unchanged lines hidden (view full) --- 384 */ 385 if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) || 386 (sigaddset(&s_mask,SIGINT) < 0)||(sigaddset(&s_mask,SIGHUP) < 0) || 387 (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0) || 388 (sigaddset(&s_mask,SIGXCPU) < 0)||(sigaddset(&s_mask,SIGXFSZ)<0)) { 389 paxwarn(1, "Unable to set up signal mask"); 390 return(-1); 391 } | 252 253 /* 254 * Where should we put temporary files? 255 */ 256 if ((tmpdir = getenv("TMPDIR")) == NULL || *tmpdir == '\0') 257 tmpdir = _PATH_TMP; 258 tdlen = strlen(tmpdir); 259 while(tdlen > 0 && tmpdir[tdlen - 1] == '/') --- 137 unchanged lines hidden (view full) --- 397 */ 398 if ((sigemptyset(&s_mask) < 0) || (sigaddset(&s_mask, SIGTERM) < 0) || 399 (sigaddset(&s_mask,SIGINT) < 0)||(sigaddset(&s_mask,SIGHUP) < 0) || 400 (sigaddset(&s_mask,SIGPIPE) < 0)||(sigaddset(&s_mask,SIGQUIT)<0) || 401 (sigaddset(&s_mask,SIGXCPU) < 0)||(sigaddset(&s_mask,SIGXFSZ)<0)) { 402 paxwarn(1, "Unable to set up signal mask"); 403 return(-1); 404 } |
405 memset(&n_hand, 0, sizeof n_hand); |
|
392 n_hand.sa_mask = s_mask; 393 n_hand.sa_flags = 0; 394 n_hand.sa_handler = sig_cleanup; 395 396 if ((sigaction(SIGHUP, &n_hand, &o_hand) < 0) && 397 (o_hand.sa_handler == SIG_IGN) && 398 (sigaction(SIGHUP, &o_hand, &o_hand) < 0)) 399 goto out; --- 31 unchanged lines hidden --- | 406 n_hand.sa_mask = s_mask; 407 n_hand.sa_flags = 0; 408 n_hand.sa_handler = sig_cleanup; 409 410 if ((sigaction(SIGHUP, &n_hand, &o_hand) < 0) && 411 (o_hand.sa_handler == SIG_IGN) && 412 (sigaction(SIGHUP, &o_hand, &o_hand) < 0)) 413 goto out; --- 31 unchanged lines hidden --- |