summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-01-24 19:41:24 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-01-24 19:41:24 +0000
commita77b8c21d70779c5365903c1f86d3c3126549212 (patch)
treebf5fde1d8f0b7e3b83c095147335bb9bfc34c2cb
parenta10d89c9c5edc27d0c43dc3dddc9693bbc11f7e1 (diff)
Support multiple -v options like GNU tar (> 1 -v means do ls-like output).
-rw-r--r--bin/pax/ar_subs.c28
-rw-r--r--bin/pax/extern.h4
-rw-r--r--bin/pax/gen_subs.c35
-rw-r--r--bin/pax/options.c6
4 files changed, 44 insertions, 29 deletions
diff --git a/bin/pax/ar_subs.c b/bin/pax/ar_subs.c
index cade8d4be77..164b4470163 100644
--- a/bin/pax/ar_subs.c
+++ b/bin/pax/ar_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ar_subs.c,v 1.4 1996/10/27 06:45:09 downsj Exp $ */
+/* $OpenBSD: ar_subs.c,v 1.5 1997/01/24 19:41:19 millert Exp $ */
/* $NetBSD: ar_subs.c,v 1.5 1995/03/21 09:07:06 cgd Exp $ */
/*-
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)ar_subs.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: ar_subs.c,v 1.4 1996/10/27 06:45:09 downsj Exp $";
+static char rcsid[] = "$OpenBSD: ar_subs.c,v 1.5 1997/01/24 19:41:19 millert Exp $";
#endif
#endif /* not lint */
@@ -134,7 +134,7 @@ list()
if ((res = mod_name(arcn)) < 0)
break;
if (res == 0)
- ls_list(arcn, now);
+ ls_list(arcn, now, stdout);
}
/*
@@ -175,6 +175,7 @@ extract()
ARCHD archd;
struct stat sb;
int fd;
+ time_t now;
arcn = &archd;
/*
@@ -193,6 +194,8 @@ extract()
if (iflag && (name_start() < 0))
return;
+ now = time((time_t *)NULL);
+
/*
* step through each entry on the archive until the format read routine
* says it is done
@@ -280,8 +283,12 @@ extract()
}
if (vflag) {
- (void)fputs(arcn->name, stderr);
- vfpart = 1;
+ if (vflag > 1)
+ ls_list(arcn, now, stderr);
+ else {
+ (void)fputs(arcn->name, stderr);
+ vfpart = 1;
+ }
}
/*
@@ -386,6 +393,7 @@ wr_archive(arcn, is_app)
off_t cnt;
int (*wrf)();
int fd = -1;
+ time_t now;
/*
* if this format supports hard link storage, start up the database
@@ -413,6 +421,8 @@ wr_archive(arcn, is_app)
*/
wr_one = is_app;
+ now = time((time_t *)NULL);
+
/*
* while there are files to archive, process them one at at time
*/
@@ -482,8 +492,12 @@ wr_archive(arcn, is_app)
}
if (vflag) {
- (void)fputs(arcn->name, stderr);
- vfpart = 1;
+ if (vflag > 1)
+ ls_list(arcn, now, stderr);
+ else {
+ (void)fputs(arcn->name, stderr);
+ vfpart = 1;
+ }
}
++flcnt;
diff --git a/bin/pax/extern.h b/bin/pax/extern.h
index 908c5626ba1..1a00cf3f953 100644
--- a/bin/pax/extern.h
+++ b/bin/pax/extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: extern.h,v 1.7 1996/12/09 12:00:14 deraadt Exp $ */
+/* $OpenBSD: extern.h,v 1.8 1997/01/24 19:41:20 millert Exp $ */
/* $NetBSD: extern.h,v 1.5 1996/03/26 23:54:16 mrg Exp $ */
/*-
@@ -166,7 +166,7 @@ int next_file __P((register ARCHD *));
/*
* gen_subs.c
*/
-void ls_list __P((register ARCHD *, time_t));
+void ls_list __P((register ARCHD *, time_t, FILE *));
void ls_tty __P((register ARCHD *));
void zf_strncpy __P((register char *, register char *, int));
int l_strncpy __P((register char *, register char *, int));
diff --git a/bin/pax/gen_subs.c b/bin/pax/gen_subs.c
index e4a6c15736e..554faf88faa 100644
--- a/bin/pax/gen_subs.c
+++ b/bin/pax/gen_subs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gen_subs.c,v 1.3 1996/06/23 14:20:35 deraadt Exp $ */
+/* $OpenBSD: gen_subs.c,v 1.4 1997/01/24 19:41:21 millert Exp $ */
/* $NetBSD: gen_subs.c,v 1.5 1995/03/21 09:07:26 cgd Exp $ */
/*-
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)gen_subs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: gen_subs.c,v 1.3 1996/06/23 14:20:35 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: gen_subs.c,v 1.4 1997/01/24 19:41:21 millert Exp $";
#endif
#endif /* not lint */
@@ -83,12 +83,13 @@ static char rcsid[] = "$OpenBSD: gen_subs.c,v 1.3 1996/06/23 14:20:35 deraadt Ex
#if __STDC__
void
-ls_list(register ARCHD *arcn, time_t now)
+ls_list(register ARCHD *arcn, time_t now, FILE *fp)
#else
void
-ls_list(arcn, now)
+ls_list(arcn, now, fp)
register ARCHD *arcn;
time_t now;
+ FILE *fp;
#endif
{
register struct stat *sbp;
@@ -100,8 +101,8 @@ ls_list(arcn, now)
* if not verbose, just print the file name
*/
if (!vflag) {
- (void)printf("%s\n", arcn->name);
- (void)fflush(stdout);
+ (void)fprintf(fp, "%s\n", arcn->name);
+ (void)fflush(fp);
return;
}
@@ -128,8 +129,8 @@ ls_list(arcn, now)
*/
if (strftime(f_date,DATELEN,timefrmt,localtime(&(sbp->st_mtime))) == 0)
f_date[0] = '\0';
- (void)printf("%s%2u %-*s %-*s ", f_mode, sbp->st_nlink, UT_NAMESIZE,
- name_uid(sbp->st_uid, 1), UT_GRPSIZE,
+ (void)fprintf(fp, "%s%2u %-*s %-*s ", f_mode, sbp->st_nlink,
+ UT_NAMESIZE, name_uid(sbp->st_uid, 1), UT_GRPSIZE,
name_gid(sbp->st_gid, 1));
/*
@@ -137,30 +138,30 @@ ls_list(arcn, now)
*/
if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
# ifdef NET2_STAT
- (void)printf("%4u,%4u ", MAJOR(sbp->st_rdev),
+ (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev),
# else
- (void)printf("%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
+ (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
# endif
(unsigned long)MINOR(sbp->st_rdev));
else {
# ifdef NET2_STAT
- (void)printf("%9lu ", sbp->st_size);
+ (void)fprintf(fp, "%9lu ", sbp->st_size);
# else
- (void)printf("%9qu ", sbp->st_size);
+ (void)fprintf(fp, "%9qu ", sbp->st_size);
# endif
}
/*
* print name and link info for hard and soft links
*/
- (void)printf("%s %s", f_date, arcn->name);
+ (void)fprintf(fp, "%s %s", f_date, arcn->name);
if ((arcn->type == PAX_HLK) || (arcn->type == PAX_HRG))
- (void)printf(" == %s\n", arcn->ln_name);
+ (void)fprintf(fp, " == %s\n", arcn->ln_name);
else if (arcn->type == PAX_SLK)
- (void)printf(" => %s\n", arcn->ln_name);
+ (void)fprintf(fp, " => %s\n", arcn->ln_name);
else
- (void)putchar('\n');
- (void)fflush(stdout);
+ (void)putc('\n', fp);
+ (void)fflush(fp);
return;
}
diff --git a/bin/pax/options.c b/bin/pax/options.c
index 8d84828272f..953460529b1 100644
--- a/bin/pax/options.c
+++ b/bin/pax/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.12 1996/12/09 12:02:16 deraadt Exp $ */
+/* $OpenBSD: options.c,v 1.13 1997/01/24 19:41:23 millert Exp $ */
/* $NetBSD: options.c,v 1.6 1996/03/26 23:54:18 mrg Exp $ */
/*-
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94";
#else
-static char rcsid[] = "$OpenBSD: options.c,v 1.12 1996/12/09 12:02:16 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: options.c,v 1.13 1997/01/24 19:41:23 millert Exp $";
#endif
#endif /* not lint */
@@ -697,7 +697,7 @@ tar_options(argc, argv)
/*
* verbose operation mode
*/
- vflag = 1;
+ vflag++;
break;
case 'w':
/*