-# $OpenBSD: Makefile,v 1.11 2014/01/08 04:58:36 guenther Exp $
+# $OpenBSD: Makefile,v 1.12 2016/08/23 06:00:28 guenther Exp $
+WARNINGS=Yes
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
-/* $OpenBSD: ar_io.c,v 1.57 2016/08/14 18:30:33 guenther Exp $ */
+/* $OpenBSD: ar_io.c,v 1.58 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: ar_io.c,v 1.5 1996/03/26 23:54:13 mrg Exp $ */
/*-
return;
}
- if (strcmp(NM_PAX, argv0) == 0)
+ if (op_mode == OP_PAX)
(void)dprintf(listfd, "%s: %s vol %d, %lu files,"
" %llu bytes read, %llu bytes written.\n",
argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
#ifndef NOCPIO
- else if (strcmp(NM_CPIO, argv0) == 0)
+ else if (op_mode == OP_CPIO)
(void)dprintf(listfd, "%llu blocks\n",
(rdcnt ? rdcnt : wrcnt) / 5120);
#endif /* !NOCPIO */
if (sigprocmask(SIG_SETMASK, &o_mask, NULL) < 0)
syswarn(0, errno, "Unable to restore signal mask");
- if (done || !wr_trail || force_one_volume || strcmp(NM_TAR, argv0) == 0)
+ if (done || !wr_trail || force_one_volume || op_mode == OP_TAR)
return(-1);
tty_prnt("\nATTENTION! %s archive volume change required.\n", argv0);
-/* $OpenBSD: extern.h,v 1.55 2016/08/14 04:47:52 guenther Exp $ */
+/* $OpenBSD: extern.h,v 1.56 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
extern int docrc;
extern char *dirptr;
extern char *argv0;
+extern enum op_mode { OP_PAX, OP_TAR, OP_CPIO } op_mode;
extern FILE *listf;
extern int listfd;
extern char *tempfile;
-/* $OpenBSD: file_subs.c,v 1.50 2016/08/23 03:31:44 guenther Exp $ */
+/* $OpenBSD: file_subs.c,v 1.51 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: file_subs.c,v 1.4 1995/03/21 09:07:18 cgd Exp $ */
/*-
* potential symlink chain before trying to create the
* directory.
*/
- if (strcmp(NM_TAR, argv0) == 0 && Lflag) {
+ if (op_mode == OP_TAR && Lflag) {
while (lstat(nm, &sb) == 0 &&
S_ISLNK(sb.st_mode)) {
len = readlink(nm, target,
if (pmode && !defer_pmode)
set_pmode(nm, arcn->sb.st_mode);
- if (arcn->type == PAX_DIR && strcmp(NM_CPIO, argv0) != 0) {
+ if (arcn->type == PAX_DIR && op_mode != OP_CPIO) {
/*
* Dirs must be processed again at end of extract to set times
* and modes to agree with those stored in the archive. However
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
*/
- if (strcmp(NM_PAX, argv0) == 0 || errno != EPERM || vflag ||
+ if (op_mode == OP_PAX || errno != EPERM || vflag ||
geteuid() == 0)
syswarn(1, errno, "Unable to set file uid/gid of %s",
fnm);
* ignore EPERM unless in verbose mode or being run by root.
* if running as pax, POSIX requires a warning.
*/
- if (strcmp(NM_PAX, argv0) == 0 || errno != EPERM || vflag ||
+ if (op_mode == OP_PAX || errno != EPERM || vflag ||
geteuid() == 0)
syswarn(1, errno, "Unable to set file uid/gid of %s",
fnm);
-/* $OpenBSD: options.c,v 1.94 2016/08/14 04:47:52 guenther Exp $ */
+/* $OpenBSD: options.c,v 1.95 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
argv0 = __progname;
if (strcmp(NM_TAR, argv0) == 0) {
+ op_mode = OP_TAR;
tar_options(argc, argv);
return;
}
#ifndef NOCPIO
else if (strcmp(NM_CPIO, argv0) == 0) {
+ op_mode = OP_CPIO;
cpio_options(argc, argv);
return;
}
* assume pax as the default
*/
argv0 = NM_PAX;
+ op_mode = OP_PAX;
pax_options(argc, argv);
}
-/* $OpenBSD: pax.c,v 1.45 2016/06/23 06:37:36 semarie Exp $ */
+/* $OpenBSD: pax.c,v 1.46 2016/08/23 06:00:28 guenther Exp $ */
/* $NetBSD: pax.c,v 1.5 1996/03/26 23:54:20 mrg Exp $ */
/*-
int docrc; /* check/create file crc */
char *dirptr; /* destination dir in a copy */
char *argv0; /* root of argv[0] */
+enum op_mode op_mode; /* what program are we acting as? */
sigset_t s_mask; /* signal mask for cleanup critical sect */
FILE *listf = stderr; /* file pointer to print file list to */
int listfd = STDERR_FILENO; /* fd matching listf, for sighandler output */