PR/36194: Greg A. Woods: add a '-V' flag to pax for verbose summary without

listing (and other minor fixes)
This commit is contained in:
christos 2007-04-23 18:40:22 +00:00
parent e848cdf438
commit 702d1ca548
10 changed files with 137 additions and 92 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ar_io.c,v 1.47 2006/02/11 10:43:17 dsl Exp $ */
/* $NetBSD: ar_io.c,v 1.48 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)ar_io.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: ar_io.c,v 1.47 2006/02/11 10:43:17 dsl Exp $");
__RCSID("$NetBSD: ar_io.c,v 1.48 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -379,7 +379,7 @@ ar_close(void)
* going on (this avoids the user hitting control-c thinking pax is
* broken).
*/
if (vflag && (artyp == ISTAPE)) {
if ((vflag || Vflag) && (artyp == ISTAPE)) {
if (vfpart)
(void)putc('\n', listf);
(void)fprintf(listf,
@ -416,7 +416,7 @@ ar_close(void)
if (zpid > 0)
waitpid(zpid, &status, 0);
if (vflag && (artyp == ISTAPE)) {
if ((vflag || Vflag) && (artyp == ISTAPE)) {
(void)fputs("done.\n", listf);
vfpart = 0;
(void)fflush(listf);
@ -436,7 +436,7 @@ ar_close(void)
if (frmt != NULL)
++arvol;
if (!vflag) {
if (!vflag && !Vflag) {
flcnt = 0;
return;
}
@ -448,20 +448,9 @@ ar_close(void)
(void)putc('\n', listf);
vfpart = 0;
}
/*
* If we have not determined the format yet, we just say how many bytes
* we have skipped over looking for a header to id. there is no way we
* could have written anything yet.
*/
if (frmt == NULL) {
(void)fprintf(listf, "%s: unknown format, " OFFT_F
" bytes skipped.\n", argv0, rdcnt);
(void)fflush(listf);
flcnt = 0;
return;
}
if (strcmp(NM_CPIO, argv0) == 0) {
/* mimic cpio's block count first */
if (frmt && strcmp(NM_CPIO, argv0) == 0) {
(void)fprintf(listf, OFFT_F " blocks\n",
(rdcnt ? rdcnt : wrcnt) / 5120);
}
@ -1646,10 +1635,10 @@ ar_summary(int n)
{
time_t secs;
int len;
char buf[MAXPATHLEN];
char tbuf[MAXPATHLEN/4];
char s1buf[MAXPATHLEN/8];
char s2buf[MAXPATHLEN/8];
char buf[BUFSIZ];
char tbuf[MAXPATHLEN/4]; /* XXX silly size! */
char s1buf[MAXPATHLEN/8]; /* XXX very silly size! */
char s2buf[MAXPATHLEN/8]; /* XXX very silly size! */
FILE *outf;
if (act == LIST)
@ -1683,10 +1672,11 @@ ar_summary(int n)
}
if (n != 0) {
if (n != 0 && *archd.name) {
len = snprintf(buf, sizeof(buf), "Working on `%s' (%s)\n",
archd.name, sizefmt(s1buf, sizeof(s1buf), archd.sb.st_size));
(void)write(STDERR_FILENO, buf, len);
len = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ar_subs.c,v 1.52 2007/03/08 17:01:30 rillig Exp $ */
/* $NetBSD: ar_subs.c,v 1.53 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: ar_subs.c,v 1.52 2007/03/08 17:01:30 rillig Exp $");
__RCSID("$NetBSD: ar_subs.c,v 1.53 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -802,7 +802,7 @@ append(void)
/*
* reading the archive may take a long time. If verbose tell the user
*/
if (vflag) {
if (vflag || Vflag) {
(void)fprintf(listf,
"%s: Reading archive to position at the end...", argv0);
vfpart = 1;
@ -864,7 +864,7 @@ append(void)
/*
* tell the user we are done reading.
*/
if (vflag && vfpart) {
if ((vflag || Vflag) && vfpart) {
(void)safe_print("done.\n", listf);
vfpart = 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.51 2006/04/16 16:20:21 christos Exp $ */
/* $NetBSD: extern.h,v 1.52 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -245,6 +245,7 @@ extern int Dflag;
extern int Hflag;
extern int Lflag;
extern int Mflag;
extern int Vflag;
extern int Xflag;
extern int Yflag;
extern int Zflag;

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.c,v 1.99 2007/01/16 19:06:41 cbiere Exp $ */
/* $NetBSD: options.c,v 1.100 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: options.c,v 1.99 2007/01/16 19:06:41 cbiere Exp $");
__RCSID("$NetBSD: options.c,v 1.100 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -255,8 +255,8 @@ pax_options(int argc, char **argv)
{
int c;
int i;
unsigned int flg = 0;
unsigned int bflg = 0;
u_int64_t flg = 0;
u_int64_t bflg = 0;
char *pt;
FSUB tmp;
@ -264,7 +264,7 @@ pax_options(int argc, char **argv)
* process option flags
*/
while ((c = getopt_long(argc, argv,
"0ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:XYZ",
"0ab:cdf:ijklno:p:rs:tuvwx:zAB:DE:G:HLMN:OPT:U:VXYZ",
pax_longopts, NULL)) != -1) {
switch (c) {
case '0':
@ -606,6 +606,13 @@ pax_options(int argc, char **argv)
}
flg |= CUF;
break;
case 'V':
/*
* somewhat verbose operation mode (no listing)
*/
Vflag = 1;
flg |= VSF;
break;
case 'X':
/*
* do not pass over mount points in the file system
@ -751,6 +758,8 @@ struct option tar_longopts[] = {
{ "absolute-paths", no_argument, 0, 'P' },
{ "sparse", no_argument, 0, 'S' },
{ "files-from", required_argument, 0, 'T' },
{ "summary", no_argument, 0, 'V' },
{ "stats", no_argument, 0, 'V' },
{ "exclude-from", required_argument, 0, 'X' },
{ "compress", no_argument, 0, 'Z' },
{ "uncompress", no_argument, 0, 'Z' },
@ -804,8 +813,8 @@ struct option tar_longopts[] = {
OPT_NULL },
{ "totals", no_argument, 0,
OPT_TOTALS },
{ "volume-name", required_argument, 0, 'V' },
{ "label", required_argument, 0, 'V' },
{ "volume-name", required_argument, 0, 'V' }, /* XXX */
{ "label", required_argument, 0, 'V' }, /* XXX */
{ "version", no_argument, 0,
OPT_VERSION },
{ "verify", no_argument, 0, 'W' },
@ -1046,6 +1055,12 @@ tar_options(int argc, char **argv)
case 'S':
/* do nothing; we already generate sparse files */
break;
case 'V':
/*
* semi-verbose operation mode (no listing)
*/
Vflag = 1;
break;
case 'X':
/*
* GNU tar compat: exclude the files listed in optarg
@ -1397,6 +1412,8 @@ struct option cpio_longopts[] = {
{ "format", required_argument, 0, 'H' },
{ "dereference", no_argument, 0, 'L' },
{ "swap-halfwords", no_argument, 0, 'S' },
{ "summary", no_argument, 0, 'V' },
{ "stats", no_argument, 0, 'V' },
{ "insecure", no_argument, 0,
OPT_INSECURE },
{ "sparse", no_argument, 0,
@ -1410,7 +1427,7 @@ struct option cpio_longopts[] = {
{ "swap-bytes", no_argument, 0, 's' },
{ "message", required_argument, 0, 'M' },
{ "owner", required_argument, 0 'R' },
{ "dot", no_argument, 0, 'V' },
{ "dot", no_argument, 0, 'V' }, /* xxx */
{ "block-size", required_argument, 0,
OPT_BLOCK_SIZE },
{ "no-absolute-pathnames", no_argument, 0,
@ -1448,8 +1465,8 @@ static void
cpio_options(int argc, char **argv)
{
FSUB tmp;
unsigned int flg = 0;
unsigned int bflg = 0;
u_int64_t flg = 0;
u_int64_t bflg = 0;
int c, i;
FILE *fp;
char *str;
@ -1680,9 +1697,16 @@ cpio_options(int argc, char **argv)
cpio_swp_head = 1;
break;
#ifdef notyet
case 'V':
case 'V': /* print a '.' for each file processed */
break;
#endif
case 'V':
/*
* semi-verbose operation mode (no listing)
*/
Vflag = 1;
flg |= VF;
break;
case 'Z':
/*
* use compress. Non standard option.

View File

@ -1,4 +1,4 @@
/* $NetBSD: options.h,v 1.10 2004/05/11 17:12:26 christos Exp $ */
/* $NetBSD: options.h,v 1.11 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -43,54 +43,57 @@
#define NM_CPIO "cpio"
#define NM_PAX "pax"
/* special value for -E */
#define none "none"
/*
* Constants used to specify the legal sets of flags in pax. For each major
* operation mode of pax, a set of illegal flags is defined. If any one of
* those illegal flags are found set, we scream and exit
*/
#define none "none"
/*
* flags (one for each option).
*/
#define AF 0x00000001
#define BF 0x00000002
#define CF 0x00000004
#define DF 0x00000008
#define FF 0x00000010
#define IF 0x00000020
#define KF 0x00000040
#define LF 0x00000080
#define NF 0x00000100
#define OF 0x00000200
#define PF 0x00000400
#define RF 0x00000800
#define SF 0x00001000
#define TF 0x00002000
#define UF 0x00004000
#define VF 0x00008000
#define WF 0x00010000
#define XF 0x00020000
#define CAF 0x00040000 /* nonstandard extension */
#define CBF 0x00080000 /* nonstandard extension */
#define CDF 0x00100000 /* nonstandard extension */
#define CEF 0x00200000 /* nonstandard extension */
#define CGF 0x00400000 /* nonstandard extension */
#define CHF 0x00800000 /* nonstandard extension */
#define CLF 0x01000000 /* nonstandard extension */
#define CMF 0x02000000 /* nonstandard extension */
#define CPF 0x04000000 /* nonstandard extension */
#define CTF 0x08000000 /* nonstandard extension */
#define CUF 0x10000000 /* nonstandard extension */
#define CXF 0x20000000
#define CYF 0x40000000 /* nonstandard extension */
#define CZF 0x80000000 /* nonstandard extension */
#define AF 0x000000001ULL
#define BF 0x000000002ULL
#define CF 0x000000004ULL
#define DF 0x000000008ULL
#define FF 0x000000010ULL
#define IF 0x000000020ULL
#define KF 0x000000040ULL
#define LF 0x000000080ULL
#define NF 0x000000100ULL
#define OF 0x000000200ULL
#define PF 0x000000400ULL
#define RF 0x000000800ULL
#define SF 0x000001000ULL
#define TF 0x000002000ULL
#define UF 0x000004000ULL
#define VF 0x000008000ULL
#define WF 0x000010000ULL
#define XF 0x000020000ULL
#define CAF 0x000040000ULL /* nonstandard extension */
#define CBF 0x000080000ULL /* nonstandard extension */
#define CDF 0x000100000ULL /* nonstandard extension */
#define CEF 0x000200000ULL /* nonstandard extension */
#define CGF 0x000400000ULL /* nonstandard extension */
#define CHF 0x000800000ULL /* nonstandard extension */
#define CLF 0x001000000ULL /* nonstandard extension */
#define CMF 0x002000000ULL /* nonstandard extension */
#define CPF 0x004000000ULL /* nonstandard extension */
#define CTF 0x008000000ULL /* nonstandard extension */
#define CUF 0x010000000ULL /* nonstandard extension */
#define VSF 0x020000000ULL /* non-standard */
#define CXF 0x040000000ULL
#define CYF 0x080000000ULL /* nonstandard extension */
#define CZF 0x100000000ULL /* nonstandard extension */
/*
* ascii string indexed by bit position above (alter the above and you must
* alter this string) used to tell the user what flags caused us to complain
*/
#define FLGCH "abcdfiklnoprstuvwxABDEGHLMPTUXYZ"
#define FLGCH "abcdfiklnoprstuvwxABDEGHLMPTUVXYZ"
/*
* legal pax operation bit patterns

View File

@ -1,4 +1,4 @@
.\" $NetBSD: pax.1,v 1.51 2006/08/22 17:42:19 christos Exp $
.\" $NetBSD: pax.1,v 1.52 2007/04/23 18:40:22 christos Exp $
.\"
.\" Copyright (c) 1992 Keith Muller.
.\" Copyright (c) 1992, 1993
@ -41,7 +41,7 @@
.Nd read and write file archives and copy directory hierarchies
.Sh SYNOPSIS
.Nm
.Op Fl 0cdjnvzO
.Op Fl 0cdjnvzVO
.Bk -words
.Op Fl E Ar limit
.Ek
@ -76,7 +76,7 @@
.Op Ar pattern ...\&
.Nm
.Fl r
.Op Fl cdijknuvzADOYZ
.Op Fl cdijknuvzADOVYZ
.Bk -words
.Op Fl E Ar limit
.Ek
@ -119,7 +119,7 @@
.Op Ar pattern ...\&
.Nm
.Fl w
.Op Fl dijtuvzAHLMOPX
.Op Fl dijtuvzAHLMOPVX
.Bk -words
.Op Fl b Ar blocksize
.Ek
@ -167,7 +167,7 @@
.Nm
.Fl r
.Fl w
.Op Fl dijklntuvzADHLMOPXYZ
.Op Fl dijklntuvzADHLMOPVXYZ
.Bk -words
.Op Fl N Ar dbdir
.Ek
@ -712,6 +712,7 @@ is the output format specified by the
utility when used with the
.Fl l
option.
.Pp
Otherwise for all the other operational modes
.Em ( read , write ,
and
@ -725,6 +726,9 @@ archive member.
The trailing
.Aq Dv newline ,
is not buffered, and is written only after the file has been read or written.
.Pp
A final summary of archive operations is printed after they have been
completed.
.It Fl x Ar format
Specify the output archive format, with the default format being
.Ar ustar .
@ -1060,6 +1064,9 @@ A '\\' can be used to escape the
Multiple
.Fl U
options may be supplied and checking stops with the first match.
.It Fl V
A final summary of archive operations is printed after they have been
completed. Some potentially long-running tape operations are noted.
.It Fl X
When traversing the file hierarchy specified by a pathname,
do not descend into directories that have a different device ID.

View File

@ -1,4 +1,4 @@
/* $NetBSD: pax.c,v 1.40 2006/02/11 11:04:57 dsl Exp $ */
/* $NetBSD: pax.c,v 1.41 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: pax.c,v 1.40 2006/02/11 11:04:57 dsl Exp $");
__RCSID("$NetBSD: pax.c,v 1.41 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -91,6 +91,7 @@ int Dflag; /* same as uflag except inode change time */
int Hflag; /* follow command line symlinks (write only) */
int Lflag; /* follow symlinks when writing */
int Mflag; /* treat stdin as an mtree(8) specfile */
int Vflag; /* produce somewhat verbose output (no listing) */
int Xflag; /* archive files with same device id only */
int Yflag; /* same as Dflg except after name mode */
int Zflag; /* same as uflg except after name mode */

View File

@ -1,4 +1,4 @@
.\" $NetBSD: tar.1,v 1.22 2005/05/24 00:05:01 wiz Exp $
.\" $NetBSD: tar.1,v 1.23 2007/04/23 18:40:22 christos Exp $
.\"
.\" Copyright (c) 1996 SigmaSoft, Th. Lockert
.\" All rights reserved.
@ -115,7 +115,8 @@ This option is a GNU extension.
.It Fl k , -keep-old-files
Keep existing files; don't overwrite them from archive.
.It Fl l , -one-file-system
Do not cross filesystems.
Do not descend across mount points.
.\" should be '-X'
.It Fl m , -modification-time
Do not preserve modification time.
.It Fl O
@ -216,7 +217,21 @@ from the directory.
This argument and its parameter may also appear in a file list specified by
.Fl T .
.It Fl H
Follow symlinks given on command line only.
Only follow symlinks given on command line.
.Pp
Note SysVr3/i386 picked up ISC/SCO UNIX compatabilty which implemented
.Dq Fl F Ar file
which was defined as obtaining a list of command line switches and files
on which to operate from the specified file,
but SunOS-5 uses
.Dq Fl I Ar file
because they use
.Sq Fl F
to mean something else. We might someday provide SunOS-5 compatability
but it makes little sense to confuse things with ISC/SCO compatability.
.\".It Fl L
.\"Do not follow any symlinks (do the opposite of
.\".Fl h ).
.It Fl P , -absolute-paths
Do not strip leading slashes
.Pq Sq /
@ -229,6 +244,10 @@ A line may also specify the positional argument
.Dq Fl C Ar directory .
.It Fl X Ar file , Fl -exclude-from Ar file
Exclude files listed in the given file.
.\" exclude should be '-E' and '-X' should be one-file-system
.Pp
Note that it would be more standard to use this option to mean ``do not
cross filesystem mount points.''
.It Fl Z , -compress , -uncompress
Compress archive using compress.
.It Fl -strict

View File

@ -1,4 +1,4 @@
/* $NetBSD: tar.c,v 1.64 2006/03/18 05:43:47 christos Exp $ */
/* $NetBSD: tar.c,v 1.65 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: tar.c,v 1.64 2006/03/18 05:43:47 christos Exp $");
__RCSID("$NetBSD: tar.c,v 1.65 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -85,7 +85,7 @@ static int check_sum(char *, size_t, char *, size_t, int);
static int tar_nodir; /* do not write dirs under old tar */
int is_gnutar; /* behave like gnu tar; enable gnu
* extensions and skip end-ofvolume
* extensions and skip end-of-volume
* checks
*/
static int seen_gnu_warning; /* Have we warned yet? */
@ -789,7 +789,7 @@ ustar_id(char *blk, int size)
!seen_gnu_warning) {
seen_gnu_warning = 1;
tty_warn(0,
"Trying to read GNU tar archive with extensions off");
"Trying to read GNU tar archive with GNU extensions and end-of-volume checks off");
}
return check_sum(hd->chksum, sizeof(hd->chksum), blk, BLKMULT, 0);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tty_subs.c,v 1.18 2006/02/11 10:43:18 dsl Exp $ */
/* $NetBSD: tty_subs.c,v 1.19 2007/04/23 18:40:22 christos Exp $ */
/*-
* Copyright (c) 1992 Keith Muller.
@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)tty_subs.c 8.2 (Berkeley) 4/18/94";
#else
__RCSID("$NetBSD: tty_subs.c,v 1.18 2006/02/11 10:43:18 dsl Exp $");
__RCSID("$NetBSD: tty_subs.c,v 1.19 2007/04/23 18:40:22 christos Exp $");
#endif
#endif /* not lint */
@ -156,7 +156,7 @@ tty_warn(int set, const char *fmt, ...)
* when vflag we better ship out an extra \n to get this message on a
* line by itself
*/
if (vflag && vfpart) {
if ((Vflag || vflag) && vfpart) {
(void)fputc('\n', stderr);
vfpart = 0;
}
@ -183,7 +183,7 @@ syswarn(int set, int errnum, const char *fmt, ...)
* when vflag we better ship out an extra \n to get this message on a
* line by itself
*/
if (vflag && vfpart) {
if ((Vflag || vflag) && vfpart) {
(void)fputc('\n', stdout);
vfpart = 0;
}