From efbe733bd16953dc8653aa691090dcbcc6df3a90 Mon Sep 17 00:00:00 2001 From: Hasso Tepper Date: Fri, 27 Mar 2009 10:32:47 +0200 Subject: [PATCH] Add a -O option: force one volume. This causes pax to not prompt for a new volume upon premature end-of-volume (e.g. broken pipe). This is especially useful in automated environments where error recovery cannot be performed by a human. Unbreaks a lot of pkgsrc packages. Obtained-from: NeBSD --- bin/pax/ar_io.c | 3 ++- bin/pax/extern.h | 1 + bin/pax/options.c | 8 +++++++- bin/pax/pax.1 | 16 +++++++++++----- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/bin/pax/ar_io.c b/bin/pax/ar_io.c index faa503be42..7b0b9d8123 100644 --- a/bin/pax/ar_io.c +++ b/bin/pax/ar_io.c @@ -80,6 +80,7 @@ static int can_unlnk = 0; /* do we unlink null archives? */ char *arcname; /* printable name of archive */ const char *gzip_program; /* name of gzip program */ static pid_t zpid = -1; /* pid of child process */ +int force_one_volume; /* 1 if we ignore volume changes */ static int get_phys (void); extern sigset_t s_mask; @@ -1111,7 +1112,7 @@ ar_next(void) if (sigprocmask(SIG_SETMASK, &o_mask, NULL) < 0) syswarn(0, errno, "Unable to restore signal mask"); - if (done || !wr_trail || strcmp(NM_TAR, argv0) == 0) + if (done || !wr_trail || force_one_volume || strcmp(NM_TAR, argv0) == 0) return(-1); tty_prnt("\nATTENTION! %s archive volume change required.\n", argv0); diff --git a/bin/pax/extern.h b/bin/pax/extern.h index 1e3801a8a7..88ec21a302 100644 --- a/bin/pax/extern.h +++ b/bin/pax/extern.h @@ -50,6 +50,7 @@ */ extern char *arcname; extern const char *gzip_program; +extern int force_one_volume; int ar_open (char *); void ar_close (void); void ar_drain (void); diff --git a/bin/pax/options.c b/bin/pax/options.c index bbb5802c59..a36c40483b 100644 --- a/bin/pax/options.c +++ b/bin/pax/options.c @@ -188,7 +188,7 @@ pax_options(int argc, char **argv) /* * process option flags */ - while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ")) + while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLOPT:U:XYZ")) != -1) { switch (c) { case 'a': @@ -441,6 +441,12 @@ pax_options(int argc, char **argv) Lflag = 1; flg |= CLF; break; + case 'O': + /* + * Force one volume. Non standard option. + */ + force_one_volume = 1; + break; case 'P': /* * do NOT follow symlinks (default) diff --git a/bin/pax/pax.1 b/bin/pax/pax.1 index 2649c03306..b6462575fd 100644 --- a/bin/pax/pax.1 +++ b/bin/pax/pax.1 @@ -37,7 +37,7 @@ .\" $FreeBSD: src/bin/pax/pax.1,v 1.12.2.10 2003/02/23 17:46:34 keramida Exp $ .\" $DragonFly: src/bin/pax/pax.1,v 1.4 2007/10/20 17:56:46 swildner Exp $ .\" -.Dd April 18, 1994 +.Dd March 27, 2009 .Dt PAX 1 .Os .Sh NAME @@ -45,7 +45,7 @@ .Nd read and write file archives and copy directory hierarchies .Sh SYNOPSIS .Nm -.Op Fl cdnvz +.Op Fl cdnvzO .Bk -words .Op Fl f Ar archive .Ek @@ -72,7 +72,7 @@ .Op Ar pattern ...\& .Nm .Fl r -.Op Fl cdiknuvzDYZ +.Op Fl cdiknuvzDOYZ .Bk -words .Op Fl f Ar archive .Ek @@ -108,7 +108,7 @@ .Op Ar pattern ...\& .Nm .Fl w -.Op Fl dituvzHLPX +.Op Fl dituvzHLOPX .Bk -words .Op Fl b Ar blocksize .Ek @@ -151,7 +151,7 @@ .Nm .Fl r .Fl w -.Op Fl diklntuvDHLPXYZ +.Op Fl diklntuvDHLOPXYZ .Bk -words .Op Fl p Ar string .Ar ...\& @@ -843,6 +843,11 @@ Follow only command line symbolic links while performing a physical file system traversal. .It Fl L Follow all symbolic links to perform a logical file system traversal. +.It Fl O +Force the archive to be one volume. If a volume ends prematurely, +.Nm +will not prompt for a new volume. This option can be useful for +automated tasks where error recovery cannot be performed by a human. .It Fl P Do not follow symbolic links, perform a physical file system traversal. This is the default mode. @@ -1168,6 +1173,7 @@ The options .Fl G , .Fl H , .Fl L , +.Fl O , .Fl P , .Fl T , .Fl U , -- 2.41.0