changeset 13767:8c906b14afbd

1154 cpio needs a quiet option Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Reviewed by: Milan Jurik <milan.jurik@xylab.cz> Approved by: Richard Lowe <richlowe@richlowe.net>
author Gary Mills <gary_mills@fastmail.fm>
date Tue, 07 Aug 2012 21:36:09 -0500
parents adffc698eaf5
children ed21ea5d20cf
files usr/src/cmd/cpio/cpio.c usr/src/cmd/cpio/cpio.h usr/src/man/man1/cpio.1
diffstat 3 files changed, 34 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/cpio/cpio.c	Tue Jul 24 18:52:10 2012 -0500
+++ b/usr/src/cmd/cpio/cpio.c	Tue Aug 07 21:36:09 2012 -0500
@@ -21,6 +21,7 @@
 /*
  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012 Milan Jurik. All rights reserved.
+ * Copyright (c) 2012 Gary Mills
  */
 
 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
@@ -825,8 +826,11 @@
 		if (close(Archive) != 0)
 			msg(EXTN, "close error");
 	}
-	Blocks = (u_longlong_t)(Blocks * Bufsize + SBlocks + 0x1FF) >> 9;
-	msg(EPOST, "%lld blocks", Blocks);
+	if ((Args & OCq) == 0) {
+		Blocks = (u_longlong_t)(Blocks * Bufsize + SBlocks +
+		    0x1FF) >> 9;
+		msg(EPOST, "%lld blocks", Blocks);
+	}
 	if (Error_cnt)
 		msg(EPOST, "%d error(s)", Error_cnt);
 	return (EXIT_CODE);
@@ -6379,24 +6383,24 @@
 #if defined(O_XATTR)
 #if defined(_PC_SATTR_ENABLED)
 #ifdef WAITAROUND
-	char	*opts_p = "zabcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6@/";
+	char	*opts_p = "zabcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6@/";
 #else
-	char	*opts_p = "abcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6@/";
+	char	*opts_p = "abcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6@/";
 #endif	/* WAITAROUND */
 
 #else	/* _PC_SATTR_ENABLED */
 #ifdef WAITAROUND
-	char	*opts_p = "zabcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6@";
+	char	*opts_p = "zabcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6@";
 #else
-	char	*opts_p = "abcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6@";
+	char	*opts_p = "abcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6@";
 #endif	/* WAITAROUND */
 #endif	/* _PC_SATTR_ENABLED */
 
 #else	/* O_XATTR */
 #ifdef WAITAROUND
-	char	*opts_p = "zabcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6";
+	char	*opts_p = "zabcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6";
 #else
-	char	*opts_p = "abcdfiklmoprstuvABC:DE:H:I:LM:O:PR:SV6";
+	char	*opts_p = "abcdfiklmopqrstuvABC:DE:H:I:LM:O:PR:SV6";
 #endif	/* WAITAROUND */
 #endif	/* O_XATTR */
 
@@ -6468,6 +6472,9 @@
 			Max_namesz = APATH;
 			Args |= OCp;
 			break;
+		case 'q':	/* "quiet" */
+			Args |= OCq;
+			break;
 		case 'r':	/* rename files interactively */
 			Args |= OCr;
 			break;
@@ -6867,7 +6874,7 @@
 	(void) fflush(stdout);
 #if defined(O_XATTR)
 	(void) fprintf(stderr, gettext("USAGE:\n"
-	    "\tcpio -i[bcdfkmrstuv@BSV6] [-C size] "
+	    "\tcpio -i[bcdfkmqrstuv@BSV6] [-C size] "
 	    "[-E file] [-H hdr] [-I file [-M msg]] "
 	    "[-R id] [patterns]\n"
 	    "\tcpio -o[acv@ABLV] [-C size] "
@@ -6875,7 +6882,7 @@
 	    "\tcpio -p[adlmuv@LV] [-R id] directory\n"));
 #else
 	(void) fprintf(stderr, gettext("USAGE:\n"
-	    "\tcpio -i[bcdfkmrstuvBSV6] [-C size] "
+	    "\tcpio -i[bcdfkmqrstuvBSV6] [-C size] "
 	    "[-E file] [-H hdr] [-I file [-M msg]] "
 	    "[-R id] [patterns]\n"
 	    "\tcpio -o[acvABLV] [-C size] "
--- a/usr/src/cmd/cpio/cpio.h	Tue Jul 24 18:52:10 2012 -0500
+++ b/usr/src/cmd/cpio/cpio.h	Tue Aug 07 21:36:09 2012 -0500
@@ -19,6 +19,8 @@
  * CDDL HEADER END
  */
 /*
+ * Copyright (c) 2012 Gary Mills
+ *
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
@@ -69,6 +71,7 @@
 #define	OC6	0x10000000
 #define	BSM	0x20000000
 #define	OCP	0x40000000
+#define	OCq	0x80000000
 
 /* Sparse file support */
 #define	C_ISSPARSE	0200000
--- a/usr/src/man/man1/cpio.1	Tue Jul 24 18:52:10 2012 -0500
+++ b/usr/src/man/man1/cpio.1	Tue Aug 07 21:36:09 2012 -0500
@@ -1,6 +1,7 @@
 '\" te
 .\" Copyright 1989 AT&T
 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright (c) 2012 Gary Mills
 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/.
 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text
@@ -16,19 +17,19 @@
 .SH SYNOPSIS
 .LP
 .nf
-\fBcpio\fR \fB-i\fR [\fB-bBcdfkmPrsStuvV6@/\fR] [\fB-C\fR \fIbufsize\fR] [\fB-E\fR \fIfile\fR]
+\fBcpio\fR \fB-i\fR [\fB-bBcdfkmPqrsStuvV6@/\fR] [\fB-C\fR \fIbufsize\fR] [\fB-E\fR \fIfile\fR]
      [\fB-H\fR \fIheader\fR] [\fB-I\fR \fI\fR [\fB-M\fR \fImessage\fR]] [\fB-R\fR \fIid\fR] [\fIpattern\fR]...
 .fi
 
 .LP
 .nf
-\fBcpio\fR \fB-o\fR [\fB-aABcLPvV@/\fR] [\fB-C\fR \fIbufsize\fR] [\fB-H\fR \fIheader\fR]
+\fBcpio\fR \fB-o\fR [\fB-aABcLPqvV@/\fR] [\fB-C\fR \fIbufsize\fR] [\fB-H\fR \fIheader\fR]
      [\fB-O\fR \fIfile\fR [\fB-M\fR \fImessage\fR]]
 .fi
 
 .LP
 .nf
-\fBcpio\fR \fB-p\fR [\fB-adlLmPuvV@/\fR] [\fB-R\fR \fIid\fR] \fIdirectory\fR
+\fBcpio\fR \fB-p\fR [\fB-adlLmPquvV@/\fR] [\fB-R\fR \fIid\fR] \fIdirectory\fR
 .fi
 
 .SH DESCRIPTION
@@ -425,6 +426,16 @@
 .sp
 .ne 2
 .na
+\fB\fB-q\fR\fR
+.ad
+.RS 14n
+Quiet. Suppresses the number of blocks message that normally is printed
+after the copy is completed.
+.RE
+
+.sp
+.ne 2
+.na
 \fB\fB-r\fR\fR
 .ad
 .RS 14n