Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Patches for pax

From: Russell Stuart <russell(at)stuart.id.au>
Date: Tue Apr 22 2003 - 01:54:52 EDT


Here is yet another version of some patches I have done to pax. This lot are against the CVS head of a week or so ago. The previous lot were for OpenBSD 3.0.

These patches are mostly add new features - not fix bugs. This does not seem to be the appropriate list to send so things - is there a better one?


This first patch GNU'ises the pax source. Pax uses some C library routines only found on BSD, such as fgetln(). I am not using a BSD platform. I emulated most of those routines in a separate library outside of the pax source. This patch only covers the cases where that was not possible. The changed code should compile on any GNU platform. There are also a couple of bug fixes here to do with handling long (as opposed to long long) off_t's.

diff -Nur pax-3.3-doc/src/ar_io.c pax-3.3-gcc/src/ar_io.c

--- pax-3.3-doc/src/ar_io.c	2003-02-03 19:06:42.000000000 +1000
+++ pax-3.3-gcc/src/ar_io.c	2003-04-22 15:15:50.000000000 +1000

@@ -388,11 +388,7 @@
* could have written anything yet. */ if (frmt == NULL) { -# ifdef LONG_OFF_T - (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n", -# else - (void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n", -# endif + (void)fprintf(listf, "%s: unknown format, %" FMT_OFF "u bytes skipped.\n", argv0, rdcnt); (void)fflush(listf); flcnt = 0;
@@ -400,14 +396,10 @@
} if (strcmp(NM_CPIO, argv0) == 0) - (void)fprintf(listf, "%qu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120); + (void)fprintf(listf, "%" FMT_OFF "u blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120); else if (strcmp(NM_TAR, argv0) != 0) (void)fprintf(listf, -# ifdef LONG_OFF_T - "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n", -# else - "%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n", -# endif + "%s: %s vol %d, %lu files, %" FMT_OFF "u bytes read, %" FMT_OFF "u bytes written.\n", argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt); (void)fflush(listf); flcnt = 0; diff -Nur pax-3.3-doc/src/ar_subs.c pax-3.3-gcc/src/ar_subs.c --- pax-3.3-doc/src/ar_subs.c 2003-02-03 19:06:43.000000000 +1000 +++ pax-3.3-gcc/src/ar_subs.c 2003-04-22 15:15:50.000000000 +1000

@@ -57,6 +57,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "pax.h"
 #include "extern.h"
 
diff -Nur pax-3.3-doc/src/cpio.c pax-3.3-gcc/src/cpio.c
--- pax-3.3-doc/src/cpio.c	2003-02-03 19:06:43.000000000 +1000
+++ pax-3.3-gcc/src/cpio.c	2003-04-22 15:15:50.000000000 +1000

@@ -223,13 +223,8 @@
*/ if ((arcn->sb.st_size == 0) || (arcn->sb.st_size >= sizeof(arcn->ln_name))) { -# ifdef LONG_OFF_T
Do you need help?X
- paxwarn(1, "Cpio link name length is invalid: %lu", - arcn->sb.st_size); -# else - paxwarn(1, "Cpio link name length is invalid: %qu", + paxwarn(1, "Cpio link name length is invalid: %" FMT_OFF "u", arcn->sb.st_size); -# endif return(-1); } diff -Nur pax-3.3-doc/src/extern.h pax-3.3-gcc/src/extern.h --- pax-3.3-doc/src/extern.h 2002-10-19 01:38:11.000000000 +1000 +++ pax-3.3-gcc/src/extern.h 2003-04-22 15:15:50.000000000 +1000

@@ -302,3 +302,12 @@
 int tty_read(char *, int);
 void paxwarn(int, const char *, ...);
 void syswarn(int, int, const char *, ...);
+
+/*
+ * Handle printing of offsets.
+ */
+#ifdef	LONG_OFF_T
+#define	FMT_OFF	"l"
+#else
+#define	FMT_OFF	"q"

+#endif
diff -Nur pax-3.3-doc/src/gen_subs.c pax-3.3-gcc/src/gen_subs.c
--- pax-3.3-doc/src/gen_subs.c	2002-10-17 05:20:02.000000000 +1000
+++ pax-3.3-gcc/src/gen_subs.c	2003-04-22 15:15:50.000000000 +1000

@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include "pax.h"
 #include "extern.h"

@@ -128,19 +129,11 @@
* print device id's for devices, or sizes for other nodes */ if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK)) -# ifdef LONG_OFF_T - (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev), -# else - (void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev), -# endif + (void)fprintf(fp, "%4lu,%4lu ", + (unsigned long)MAJOR(sbp->st_rdev), (unsigned long)MINOR(sbp->st_rdev)); - else { -# ifdef LONG_OFF_T - (void)fprintf(fp, "%9lu ", sbp->st_size); -# else - (void)fprintf(fp, "%9qu ", sbp->st_size); -# endif - } + else + (void)fprintf(fp, "%9" FMT_OFF "u ", sbp->st_size); /* * print name and link info for hard and soft links diff -Nur pax-3.3-doc/src/options.c pax-3.3-gcc/src/options.c --- pax-3.3-doc/src/options.c 2003-02-03 19:06:43.000000000 +1000
Do you need more help?X
+++ pax-3.3-gcc/src/options.c 2003-04-22 15:15:50.000000000 +1000

@@ -76,7 +76,7 @@
 static void printflg(unsigned int);
 static int c_frmt(const void *, const void *);  static off_t str_offt(char *);
-static char *getline(FILE *fp);
+static char *getln(FILE *fp);
 static void pax_options(int, char **);
 static void pax_usage(void);
 static void tar_options(int, char **);

@@ -87,7 +87,7 @@
 /* errors from getline */
 #define GETLINE_FILE_CORRUPT 1
 #define GETLINE_OUT_OF_MEM 2
-static int getline_error;
+static int getln_error;    

 #define GZIP_CMD "gzip" /* command to run as gzip */
@@ -520,6 +520,7 @@

  • or list. check that we have not been given a bogus set of flags
  • for the operation mode. */ + listf = stderr; if (ISLIST(flg)) { act = LIST; listf = stdout;
    @@ -870,14 +871,14 @@
    paxwarn(1, "Unable to open file '%s' for read", file); tar_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = getln(fp)) != NULL) { if (pat_add(str, dir) < 0) tar_usage(); sawpat = 1; } if (strcmp(file, "-") != 0) fclose(fp); - if (getline_error) { + if (getln_error) { paxwarn(1, "Problem with file '%s'", file); tar_usage(); }
    @@ -943,13 +944,13 @@
    paxwarn(1, "Unable to open file '%s' for read", file); tar_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = getln(fp)) != NULL) { if (ftree_add(str, 0) < 0) tar_usage(); } if (strcmp(file, "-") != 0) fclose(fp); - if (getline_error) { + if (getln_error) { paxwarn(1, "Problem with file '%s'", file); tar_usage();
    @@ -1030,6 +1031,7 @@
    dflag = 1; act = -1; nodirs = 1; + listf = stderr; while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) switch (c) { case 'a':
    @@ -1156,11 +1158,11 @@
    paxwarn(1, "Unable to open file '%s' for read", optarg); cpio_usage(); } - while ((str = getline(fp)) != NULL) { + while ((str = getln(fp)) != NULL) { pat_add(str, NULL); } fclose(fp); - if (getline_error) { + if (getln_error) { paxwarn(1, "Problem with file '%s'", optarg); cpio_usage(); }
    @@ -1255,10 +1257,10 @@
    • no read errors allowed on updates/append operation! */ maxflt = 0; - while ((str = getline(stdin)) != NULL) { + while ((str = getln(stdin)) != NULL) { ftree_add(str, NULL); } - if (getline_error) { + if (getln_error) { paxwarn(1, "Problem while reading stdin"); cpio_usage(); }
      @@ -1483,29 +1485,40 @@
      return(num); }
+/*
+ * getln()
+ *	read a line and return it in a malloc'ed buffer.
+ *
+ *	In pax 3.0 this was called my_getline().  somewhere
+ *	between 3.0 and 3.3 it was replaced with a function
+ *	called getline() that did the same thing as my_getline()
+ *	but used fgetln().  fgetln() is not a GNU function - its
+ *	only available on BSD, and that made life difficult.
+ *	Very difficult in fact, as the easiy way to emulate
+ *	fgetln() is to use the GNU getline() function, buts its
+ *	name clashed with the one defined here.  This third
+ *	re-write is shorter and faster than the previous two,
+ *	and is compatible with GNU libc.
+ */

 char *
-getline(FILE *f)
+getln(FILE * f)
 {
-	char *name, *temp;
+	char *name = 0;
+	size_t buflen = 0;
 	size_t len;
 
-	name = fgetln(f, &len);
-	if (!name) {
-		getline_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
+	len = getline(&name, &buflen, f);
+	if (len == (size_t)-1) {
+		if (name)
+			free(name);
+		getln_error = ferror(f) ? GETLINE_FILE_CORRUPT : 0;
 		return(0);
 	}
-	if (name[len-1] != '\n')
-		len++;
-	temp = malloc(len);
-	if (!temp) {
-		getline_error = GETLINE_OUT_OF_MEM;
-		return(0);
-	}
-	memcpy(temp, name, len-1);
-	temp[len-1] = 0;
-	return(temp);
+	if (name[len - 1] == '\n')
+	  	name[len - 1] = '\0';
+	return name;

 }
-
+
 /*
  * no_op()
  *	for those option functions where the archive format has nothing to do.
diff -Nur pax-3.3-doc/src/pax.c pax-3.3-gcc/src/pax.c
--- pax-3.3-doc/src/pax.c	2002-10-17 05:20:02.000000000 +1000
+++ pax-3.3-gcc/src/pax.c	2003-04-22 15:15:50.000000000 +1000

@@ -108,7 +108,7 @@
char *ltmfrmt; /* -v locale time format (if any) */ char *argv0; /* root of argv[0] */
Can we help you?X
sigset_t s_mask; /* signal mask for cleanup critical sect */ -FILE *listf = stderr; /* file pointer to print file list to */ +FILE *listf; /* file pointer to print file list to */ char *tempfile; /* tempfile to use for mkstemp(3) */ char *tempbase; /* basename of tempfile to use for mkstemp(3) */ diff -Nur pax-3.3-doc/src/sel_subs.c pax-3.3-gcc/src/sel_subs.c --- pax-3.3-doc/src/sel_subs.c 2002-10-17 05:20:02.000000000 +1000 +++ pax-3.3-gcc/src/sel_subs.c 2003-04-22 15:15:50.000000000 +1000

@@ -56,6 +56,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include "pax.h"


----------------------------------------------------------------------

This second patch replaces a patch I sent earlier (on 2003-03-21). The patch adds a -M option that causes pax/cpio/tar to treat files being modified or deleted as they are copied as warning rather than an error. A warning message it still issued, but the exit status remains at 0. The earlier version of the patch did not handle file deletion.

The rational for the patch is that I use pax to backup entire file systems and there are some files that are modified during the copy - typically log files and such. I want those files backed up and I don't care if I miss a few lines at the end, and I don't care they are deleted before pax gets to them (happens during log file rotation). So pax having a non-zero exit status because the file system was modified while during the copy is less than helpful. When the -M flag is given the non-zero exit status is reserved for something really going wrong - like a write error.

There is also a patch in here to make the pax version of cpio behave like the real cpio. The real cpio does not exit immediately if passed a filename on stdin that does not exist. Instead it behaves like pax (when invoked as pax) does - it ignores the problem file and has a non zero exit status. I did this primarily because it makes the rest of the stuff I did easier, but I think it should be behave like that regardless.

Can't find what you're looking for?X

diff -Nur pax-3.3-gcc/src/ar_io.c pax-3.3-modifyWarn/src/ar_io.c

--- pax-3.3-gcc/src/ar_io.c	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-modifyWarn/src/ar_io.c	2003-04-22 15:15:50.000000000 +1000

@@ -492,8 +492,9 @@
 
 	if (!invld_rec)
 		return(0);
-	paxwarn(1,"Cannot append, device record size %d does not support %s spec",
-		rdblksz, argv0);
+	paxwarn(1,
+	  "Cannot append, device record size %d does not support %s spec",
+	  rdblksz, argv0);
 	return(-1);

 }  

diff -Nur pax-3.3-gcc/src/ar_subs.c pax-3.3-modifyWarn/src/ar_subs.c

--- pax-3.3-gcc/src/ar_subs.c	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-modifyWarn/src/ar_subs.c	2003-04-22 15:15:50.000000000 +1000

@@ -459,7 +459,8 @@
* the link table). */ if ((fd = open(arcn->org_name, O_RDONLY, 0)) < 0) { - syswarn(1,errno, "Unable to open %s to read", + syswarn (errno == ENOENT ? 2 : 1, errno, + "Unable to open %s to read", arcn->org_name); purg_lnk(arcn); continue;
@@ -940,8 +941,8 @@
* first open source file and then create the destination file */ if ((fdsrc = open(arcn->org_name, O_RDONLY, 0)) < 0) { - syswarn(1, errno, "Unable to open %s to read", - arcn->org_name); + syswarn (errno == ENOENT ? 2 : 1, errno,
Don't know where to look next?X
+ "Unable to open %s to read", arcn->org_name); purg_lnk(arcn); continue; } diff -Nur pax-3.3-gcc/src/buf_subs.c pax-3.3-modifyWarn/src/buf_subs.c --- pax-3.3-gcc/src/buf_subs.c 2003-02-03 19:06:43.000000000 +1000 +++ pax-3.3-modifyWarn/src/buf_subs.c 2003-04-22 15:15:50.000000000 +1000

@@ -594,7 +594,7 @@
 /*
  * wr_rdfile()
  *	fill write buffer with the contents of a file. We are passed an	open
- *	file descriptor to the file an the archive structure that describes the
+ *	file descriptor to an archive structure that describes the
  *	file we are storing. The variable "left" is modified to contain the
  *	number of bytes of the file we were NOT able to write to the archive.
  *	it is important that we always write EXACTLY the number of bytes that

@@ -602,7 +602,7 @@
* bigger, so reading to the end of file would create an improper archive, * we just detect this case and warn the user. We never create a bad * archive if we can avoid it. Of course trying to archive files that are - * active is asking for trouble. It we fail, we pass back how much we + * active is asking for trouble. If we fail, we pass back how much we * could NOT copy and let the caller deal with it. * Return: * 0 ok, -1 if archive write failure. a short read of the file returns a
@@ -640,11 +640,11 @@
if (res < 0) syswarn(1, errno, "Read fault on %s", arcn->org_name); else if (size != 0L) - paxwarn(1, "File changed size during read %s", arcn->org_name); + paxwarn(2, "File changed size during read %s", arcn->org_name); else if (fstat(ifd, &sb) < 0) syswarn(1, errno, "Failed stat on %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - paxwarn(1, "File %s was modified during copy to archive", + paxwarn(2, "File %s was modified during copy to archive",
Confused? Frustrated?X
arcn->org_name); *left = size; return(0);
@@ -813,12 +813,12 @@
syswarn(1, errno, "Failed write during copy of %s to %s", arcn->org_name, arcn->name); else if (cpcnt != arcn->sb.st_size) - paxwarn(1, "File %s changed size during copy to %s", + paxwarn(2, "File %s changed size during copy to %s", arcn->org_name, arcn->name); else if (fstat(fd1, &sb) < 0) syswarn(1, errno, "Failed stat of %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - paxwarn(1, "File %s was modified during copy to %s", + paxwarn(2, "File %s was modified during copy to %s", arcn->org_name, arcn->name); /* diff -Nur pax-3.3-gcc/src/cpio.1 pax-3.3-modifyWarn/src/cpio.1 --- pax-3.3-gcc/src/cpio.1 2001-05-12 06:02:16.000000000 +1000 +++ pax-3.3-modifyWarn/src/cpio.1 2003-04-22 15:15:50.000000000 +1000

@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm cpio
 .Fl o
-.Op Fl aABcLvzZ
+.Op Fl aABcLMvzZ
 .Op Fl C Ar bytes
 .Op Fl F Ar archive
 .Op Fl H Ar format

@@ -58,7 +58,7 @@
 .Op Ar "< archive"
 .Nm cpio
 .Fl p
-.Op Fl adlLmuv
+.Op Fl adlLmMuv
 .Ar destination-directory
 .Ar "< name-list"
 .Sh DESCRIPTION

@@ -117,6 +117,8 @@

 .El
 .It Fl L
 Follow symbolic links.
+.It Fl M
+Do not treat files being modified or deleted during the copy as an error.  .It Fl v
 Be verbose about operations.
 List filenames as they are written to the archive.
@@ -255,7 +257,9 @@

 find a file while writing an archive, or cannot preserve the user  ID, group ID, file mode, or access and modification times when the  .Fl p
-option is specified, a diagnostic message is written to standard
+option is specified, or a file is modified or deleted when the
+.Fl M
+option is not specified, a diagnostic message is written to standard
 error and a non-zero exit value will be returned, but processing  will continue.
 In the case where
diff -Nur pax-3.3-gcc/src/extern.h pax-3.3-modifyWarn/src/extern.h
--- pax-3.3-gcc/src/extern.h	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-modifyWarn/src/extern.h	2003-04-22 15:15:50.000000000 +1000

@@ -223,6 +223,7 @@
 extern int Dflag;
 extern int Hflag;
 extern int Lflag;
+extern int Mflag;
 extern int Xflag;
 extern int Yflag;
 extern int Zflag;
diff -Nur pax-3.3-gcc/src/file_subs.c pax-3.3-modifyWarn/src/file_subs.c
--- pax-3.3-gcc/src/file_subs.c	2003-02-03 19:06:43.000000000 +1000
+++ pax-3.3-modifyWarn/src/file_subs.c	2003-04-22 15:15:50.000000000 +1000

@@ -1003,11 +1003,11 @@
Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X

* they can create inconsistant archive copies. */ if (cpcnt != arcn->sb.st_size) - paxwarn(1, "File changed size %s", arcn->org_name); + paxwarn(2, "File changed size during read %s", arcn->org_name); else if (fstat(fd, &sb) < 0) syswarn(1, errno, "Failed stat on %s", arcn->org_name); else if (arcn->sb.st_mtime != sb.st_mtime) - paxwarn(1, "File %s was modified during read", arcn->org_name); + paxwarn(2, "File %s was modified during read", arcn->org_name); else if (lseek(fd, (off_t)0L, SEEK_SET) < 0) syswarn(1, errno, "File rewind failed on: %s", arcn->org_name); else { diff -Nur pax-3.3-gcc/src/ftree.c pax-3.3-modifyWarn/src/ftree.c --- pax-3.3-gcc/src/ftree.c 2002-10-17 05:20:02.000000000 +1000 +++ pax-3.3-modifyWarn/src/ftree.c 2003-04-22 15:15:50.000000000 +1000
@@ -404,7 +404,8 @@
paxwarn(1,"File system cycle found at %s",ftent->fts_path); continue; case FTS_DNR: - syswarn(1, ftent->fts_errno, + syswarn(ftent->fts_errno == ENOENT ? 2 : 1, + ftent->fts_errno, "Unable to read directory %s", ftent->fts_path); continue; case FTS_ERR:
@@ -412,10 +413,13 @@
"File system traversal error"); continue; case FTS_NS: - case FTS_NSOK: - syswarn(1, ftent->fts_errno, + syswarn(ftent->fts_errno == ENOENT ? 2 : 1, + ftent->fts_errno, "Unable to access %s", ftent->fts_path); continue; + case FTS_NSOK: + paxwarn(1, "Unable to access %s", ftent->fts_path); + continue; } /*
@@ -470,7 +474,8 @@
*/ if ((cnt = readlink(ftent->fts_path, arcn->ln_name, PAXPATHLEN)) < 0) { - syswarn(1, errno, "Unable to read symlink %s", + syswarn(errno == ENOENT ? 2 : 1, errno, + "Unable to read symlink %s", ftent->fts_path); continue; } diff -Nur pax-3.3-gcc/src/options.c pax-3.3-modifyWarn/src/options.c
Do you need help?X
--- pax-3.3-gcc/src/options.c 2003-04-22 15:15:50.000000000 +1000 +++ pax-3.3-modifyWarn/src/options.c 2003-04-22 15:15:50.000000000 +1000
@@ -198,8 +198,8 @@
/* * process option flags */ - while ((c=getopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ")) - != -1) { + while ((c=getopt(argc,argv, + "ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLMPT:U:XYZ")) != -1) { switch (c) { case 'a': /*
@@ -451,6 +451,14 @@
Lflag = 1; flg |= CLF; break; + case 'M': + /* + * ignore file modified or deleted errors. + * non-standard option. + */ + Mflag = 1; + flg |= CMF; + break; case 'O': /* * Force one volume. Non standard option.
@@ -613,7 +621,7 @@
* process option flags */ while ((c = getoldopt(argc, argv, - "b:cef:hmopqruts:vwxzBC:HI:LOPXZ014578")) != -1) { + "b:cef:hmopqruts:vwxzBC:HI:LMOPXZ014578")) != -1) { switch(c) { case 'b': /*
@@ -765,6 +773,13 @@
*/ Lflag = 1; break; + case 'M': + /* + * ignore file modified or deleted errors. + * non-standard option. + */ + Mflag = 1; + break; case 'P': /* * do not remove leading '/' from pathnames
@@ -1032,7 +1047,8 @@
act = -1; nodirs = 1; listf = stderr; - while ((c=getopt(argc,argv,"abcdfiklmoprstuvzABC:E:F:H:I:LO:SZ6")) != -1) + while ((c=getopt(argc,argv, + "abcdfiklmoprstuvzABC:E:F:H:I:LMO:SZ6")) != -1) switch (c) { case 'a': /*
@@ -1203,6 +1219,12 @@
*/ Lflag = 1; break; + case 'M': + /* + * ignore file modified or deleted errors. + * non-standard option. + */ + Mflag = 1; case 'S': /* * swap halfwords after reading data
@@ -1257,6 +1279,17 @@
* no read errors allowed on updates/append operation!
Do you need more help?X
*/ maxflt = 0; + /* + * This is not a good idea for 2 reasons. Firstly the number of + * files supplied on stdin may be huge - storing them in memory + * is not such a good idea. Secondly cpio traditionally does not + * die if it can not find a file name. Instead it behaves like + * pax does when reading the files from stdin - it continues, but + * exits with a non-zero exit status. + * + * By not reading the files here cpio is forced to behave like pax + * does. + * while ((str = getln(stdin)) != NULL) { ftree_add(str, NULL); }
@@ -1264,6 +1297,7 @@
paxwarn(1, "Problem while reading stdin"); cpio_usage(); } + */ break; default: cpio_usage();
@@ -1551,14 +1585,14 @@
(void)fputs("[-U user] ... [-G group] ...\n ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); - (void)fputs(" pax -w [-dituvzHLOPX] [-b blocksize] ", stderr); + (void)fputs(" pax -w [-dituvzHLMOPX] [-b blocksize] ", stderr); (void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-s replstr] ... ", stderr); (void)fputs("[-o options] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr); (void)fputs("[file ...]\n", stderr); - (void)fputs(" pax -r -w [-diklntuvDHLOPXYZ] ", stderr); + (void)fputs(" pax -r -w [-diklntuvDHLMOPXYZ] ", stderr); (void)fputs("[-p string] ... [-s replstr] ...", stderr); (void)fputs("\n [-U user] ... [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date][/[c][m]]] ... ", stderr);

@@ -1574,7 +1608,7 @@

 void
 tar_usage(void)
 {
-	(void)fputs("usage: tar [-]{crtux}[-befhmopqsvwzHLOPXZ014578] [blocksize] ",
Can we help you?X
+ (void)fputs("usage: tar [-]{crtux}[-befhmopqsvwzHLMOPXZ014578] [blocksize] ", stderr); (void)fputs("[archive] [replstr] [-C directory] [-I file] [file ...]\n", stderr);

@@ -1589,10 +1623,10 @@

 void
 cpio_usage(void)
 {
-	(void)fputs("usage: cpio -o [-aABcLvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);
+	(void)fputs("usage: cpio -o [-aABcLMvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);
 	(void)fputs("               [-F archive] < name-list [> archive]\n", stderr);
 	(void)fputs("       cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr);
 	(void)fputs("               [-I archive] [-F archive] [pattern...] [< archive]\n", stderr);
-	(void)fputs("       cpio -p [-adlLmuvV] destination-directory < name-list\n", stderr);
+	(void)fputs("       cpio -p [-adlLmMuvV] destination-directory < name-list\n", stderr);
 	exit(1);

 }
diff -Nur pax-3.3-gcc/src/options.h pax-3.3-modifyWarn/src/options.h
--- pax-3.3-gcc/src/options.h	1996-06-24 00:20:37.000000000 +1000
+++ pax-3.3-modifyWarn/src/options.h	2003-04-22 15:15:50.000000000 +1000

@@ -82,18 +82,19 @@
#define CGF 0x00200000 /* nonstandard extension */ #define CHF 0x00400000 /* nonstandard extension */ #define CLF 0x00800000 /* nonstandard extension */ -#define CPF 0x01000000 /* nonstandard extension */ -#define CTF 0x02000000 /* nonstandard extension */ -#define CUF 0x04000000 /* nonstandard extension */ -#define CXF 0x08000000 -#define CYF 0x10000000 /* nonstandard extension */ -#define CZF 0x20000000 /* nonstandard extension */ +#define CMF 0x01000000 /* nonstandard extension */ +#define CPF 0x02000000 /* nonstandard extension */ +#define CTF 0x04000000 /* nonstandard extension */ +#define CUF 0x08000000 /* nonstandard extension */ +#define CXF 0x10000000 +#define CYF 0x20000000 /* nonstandard extension */
Can't find what you're looking for?X
+#define CZF 0x40000000 /* 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 "abcdfiklnoprstuvwxBDEGHLPTUXYZ" +#define FLGCH "abcdfiklnoprstuvwxBDEGHLMPTUXYZ"

 /*

  • legal pax operation bit patterns
    @@ -110,7 +111,7 @@
  • Illegal option flag subsets based on pax operation */
-#define	BDEXTR	(AF|BF|LF|TF|WF|XF|CBF|CHF|CLF|CPF|CXF)
+#define	BDEXTR	(AF|BF|LF|TF|WF|XF|CBF|CHF|CLF|CMF|CPF|CXF)
 #define	BDARCH	(CF|KF|LF|NF|PF|RF|CDF|CEF|CYF|CZF)
 #define	BDCOPY	(AF|BF|FF|OF|XF|CBF|CEF)
-#define	BDLIST (AF|BF|IF|KF|LF|OF|PF|RF|TF|UF|WF|XF|CBF|CDF|CHF|CLF|CPF|CXF|CYF|CZF)
+#define	BDLIST (AF|BF|IF|KF|LF|OF|PF|RF|TF|UF|WF|XF|CBF|CDF|CHF|CLF|CMF|CPF|CXF|CYF|CZF)
diff -Nur pax-3.3-gcc/src/pax.1 pax-3.3-modifyWarn/src/pax.1
--- pax-3.3-gcc/src/pax.1	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-modifyWarn/src/pax.1	2003-04-22 15:15:50.000000000 +1000

@@ -109,7 +109,7 @@
 .Op Ar pattern ...
 .Nm pax
 .Fl w
-.Op Fl dituvzHLPX
+.Op Fl dituvzHLMPX
 .Bk -words
 .Op Fl b Ar blocksize
 .Ek

@@ -835,6 +835,8 @@
 system traversal.
 .It Fl L
 Follow all symbolic links to perform a logical file system traversal. +.It Fl M
+Do not treat files being modified or deleted during the copy as an error.  .It Fl O
 Force the archive to be one volume.
 If a volume ends prematurely,
@@ -1123,8 +1125,11 @@

 find a file when writing an archive, or cannot preserve the user ID,  group ID, or file mode when the
 .Fl p
-option is specified, a diagnostic message is written to standard error -and a non-zero exit status will be returned, but processing will continue.
+option is specified, or a file is modified or deleted when the
+.Fl M
+option is not specified, a diagnostic message is written to standard
+error and a non-zero exit status will be returned, but processing
+will continue.

 In the case where
 .Nm
 cannot create a link to a file,
@@ -1175,6 +1180,7 @@
 .Fl G ,
 .Fl H ,
 .Fl L ,
+.Fl M ,
 .Fl O ,
 .Fl P ,
 .Fl T ,
diff -Nur pax-3.3-gcc/src/pax.c pax-3.3-modifyWarn/src/pax.c
--- pax-3.3-gcc/src/pax.c	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-modifyWarn/src/pax.c	2003-04-22 15:15:50.000000000 +1000

@@ -92,6 +92,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; /* follow symlinks when writing */ 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 */ diff -Nur pax-3.3-gcc/src/tar.1 pax-3.3-modifyWarn/src/tar.1 --- pax-3.3-gcc/src/tar.1 2003-03-13 06:12:35.000000000 +1000
Don't know where to look next?X
+++ pax-3.3-modifyWarn/src/tar.1 2003-04-22 15:15:50.000000000 +1000

@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm tar
 .Sm off
-.Oo \&- Oc {crtux} Op befhmopqsvwzHLOPXZ014578
+.Oo \&- Oc {crtux} Op befhmopqsvwzHLMOPXZ014578
 .Sm on
 .Op Ar blocksize
 .Op Ar archive

@@ -208,6 +208,8 @@

 In extract mode this means that a directory entry in the archive  will not overwrite an existing symbolic link, but rather what the  link ultimately points to.
+.It Fl M
+Do not treat files being modified or deleted during the copy as an error.  .It Fl P
 Do not strip leading slashes
 .Pq Sq /
@@ -282,7 +284,9 @@

 find a file while writing an archive, or cannot preserve the user  ID, group ID, file mode, or access and modification times when the  .Fl p
-option is specified, a diagnostic message is written to standard
+option is specified, or a file is modified or deleted when the
+.Fl M
+option is not specified, a diagnostic message is written to standard
 error and a non-zero exit value will be returned, but processing  will continue.
 In the case where
@@ -330,6 +334,8 @@

 .Sh CAVEATS
 The
 .Fl L
-flag is not portable to other versions of
+and
+.Fl M
+flags are not portable to other versions of
 .Nm
-where it may have a different meaning.
+where they may have a different meaning. diff -Nur pax-3.3-gcc/src/tty_subs.c pax-3.3-modifyWarn/src/tty_subs.c
--- pax-3.3-gcc/src/tty_subs.c	2003-03-05 06:27:58.000000000 +1000
+++ pax-3.3-modifyWarn/src/tty_subs.c	2003-04-22 15:15:50.000000000 +1000

@@ -142,19 +142,17 @@
 }  
 /*
- * paxwarn()
- *	write a warning message to stderr. if "set" the exit value of pax
- *	will be non-zero.
+ * vsyswarn()
+ *	write a warning message to stderr.  If the parameter "set" is:
+ *	    0 the exit value of pax will unaffected.
+ *	    1 the exit value of pax will be non-zero.
+ *	    2 the exit value of pax be non-zero if the -M flag has been given,
+ *	      otherwise the exit value is uneffected and a warning is printed.
  */
 

-void
-paxwarn(int set, const char *fmt, ...)
+static void
+vsyswarn(int set, int errnum, const char *fmt, va_list ap)  {

-	va_list ap;
-
-	va_start(ap, fmt);
-	if (set)
-		exit_val = 1;
 	/*
 	 * when vflag we better ship out an extra \n to get this message on a
 	 * line by itself

@@ -165,15 +163,38 @@
vfpart = 0; } (void)fprintf(stderr, "%s: ", argv0); + if (set == 2 && Mflag) + (void)fprintf(stderr, "Warning - "); + else if (set) + exit_val = 1; (void)vfprintf(stderr, fmt, ap); - va_end(ap); + + /* + * format and print the errno + */ + if (errnum > 0) + (void)fprintf(stderr, ": %s", strerror(errnum)); (void)fputc('\n', stderr);

 }  
 /*
+ * paxwarn()
+ *	Shorthand interface to vsyswarn() above.
+ */
+
+void
+paxwarn(int set, const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	vsyswarn(set, 0, fmt, ap);
+	va_end(ap);
+}

+
+/*
Confused? Frustrated?X
* syswarn() - * write a warning message to stderr. if "set" the exit value of pax - * will be non-zero. + * Shorthand interface to vsyswarn() above. */

 void
@@ -182,25 +203,6 @@

         va_list ap;  

 	va_start(ap, fmt);
-	if (set)
-		exit_val = 1;
-	/*
-	 * when vflag we better ship out an extra \n to get this message on a
-	 * line by itself
-	 */
-	if (vflag && vfpart) {
-		(void)fflush(listf);
-		(void)fputc('\n', stderr);
-		vfpart = 0;
-	}
-	(void)fprintf(stderr, "%s: ", argv0);
-	(void)vfprintf(stderr, fmt, ap);
+	vsyswarn(set, errnum, fmt, ap);
 	va_end(ap);
-
-	/*
-	 * format and print the errno
-	 */
-	if (errnum > 0)
-		(void)fprintf(stderr, ": %s", strerror(errnum));
-	(void)fputc('\n', stderr);

 }

This patch adds a -j switch to pax, which causes it to compress / decompress using bzip2. This is the same as GNU tar.

diff -Nur pax-3.3-modifyWarn/src/cpio.1 pax-3.3-bzip2/src/cpio.1

--- pax-3.3-modifyWarn/src/cpio.1	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-bzip2/src/cpio.1	2003-04-22 15:15:50.000000000 +1000

@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm cpio
 .Fl o
-.Op Fl aABcLMvzZ
+.Op Fl aABcjLMvzZ
 .Op Fl C Ar bytes
 .Op Fl F Ar archive
 .Op Fl H Ar format

@@ -48,7 +48,7 @@
 .Op Ar "> archive"
 .Nm cpio
 .Fl i
-.Op Fl bBcdfmrsStuvzZ6
+.Op Fl bBcdfjmrsStuvzZ6
 .Op Fl C Ar bytes
 .Op Fl E Ar file
 .Op Fl F Ar archive

@@ -115,6 +115,10 @@

 .It Ar ustar
 POSIX ustar format.
 .El
+.It Fl j
+Compress or decompress archive using
+.Xr bzip2 1
+format.

 .It Fl L
 Follow symbolic links.
 .It Fl M
@@ -123,7 +127,7 @@

 Be verbose about operations.
 List filenames as they are written to the archive.  .It Fl z
-Compress archive using
+Compress or decompress archive using
 .Xr gzip 1
 format.
 .It Fl Z
diff -Nur pax-3.3-modifyWarn/src/options.c pax-3.3-bzip2/src/options.c
--- pax-3.3-modifyWarn/src/options.c	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-bzip2/src/options.c	2003-04-22 15:15:50.000000000 +1000

@@ -92,6 +92,7 @@
 
 #define GZIP_CMD	"gzip"		/* command to run as gzip */
 #define COMPRESS_CMD	"compress"	/* command to run as compress */
+#define BZIP2_CMD	"bzip2"		/* command to run as bzip2 */
 
 /*
  *	Format specific routine table - MUST BE IN SORTED ORDER BY NAME

@@ -199,7 +200,7 @@
* process option flags */ while ((c=getopt(argc,argv, - "ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLMPT:U:XYZ")) != -1) { + "ab:cdf:ijklno:p:rs:tuvwx:zB:DE:G:HLMPT:U:XYZ")) != -1) { switch (c) { case 'a': /*
@@ -245,6 +246,12 @@
Do you need help?X

iflag = 1; flg |= IF; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'k': /* * do not clobber files that exist
@@ -621,7 +628,7 @@
* process option flags */ while ((c = getoldopt(argc, argv, - "b:cef:hmopqruts:vwxzBC:HI:LMOPXZ014578")) != -1) { + "b:cef:hjmopqruts:vwxzBC:HI:LMOPXZ014578")) != -1) { switch(c) { case 'b': /*
@@ -666,6 +673,12 @@
*/ Lflag = 1; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'm': /* * do not preserve modification time
@@ -1048,7 +1061,7 @@
nodirs = 1; listf = stderr; while ((c=getopt(argc,argv, - "abcdfiklmoprstuvzABC:E:F:H:I:LMO:SZ6")) != -1) + "abcdfijklmoprstuvzABC:E:F:H:I:LMO:SZ6")) != -1) switch (c) { case 'a': /*
@@ -1085,6 +1098,12 @@
*/ act = EXTRACT; break; + case 'j': + /* + * use bzip2. Non standard option. + */ + gzip_program = BZIP2_CMD; + break; case 'k': break; case 'l':

@@ -1574,18 +1593,18 @@

 void
 pax_usage(void)
 {
-	(void)fputs("usage: pax [-cdnvzO] [-E limit] [-f archive] ", stderr);
+	(void)fputs("usage: pax [-cdjnvzO] [-E limit] [-f archive] ", stderr);
 	(void)fputs("[-s replstr] ... [-U user] ...", stderr);
 	(void)fputs("\n           [-G group] ... ", stderr);
 	(void)fputs("[-T [from_date][,to_date]] ... ", stderr);
 	(void)fputs("[pattern ...]\n", stderr);
-	(void)fputs("       pax -r [-cdiknuvzDOYZ] [-E limit] ", stderr);
+	(void)fputs("       pax -r [-cdijknuvzDOYZ] [-E limit] ", stderr);
 	(void)fputs("[-f archive] [-o options] ... \n", stderr);
 	(void)fputs("           [-p string] ... [-s replstr] ... ", stderr);
 	(void)fputs("[-U user] ... [-G group] ...\n	      ", stderr);
Do you need more help?X
(void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); - (void)fputs(" pax -w [-dituvzHLMOPX] [-b blocksize] ", stderr); + (void)fputs(" pax -w [-dijtuvzHLMOPX] [-b blocksize] ", stderr); (void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-s replstr] ... ", stderr); (void)fputs("[-o options] ... [-U user] ...", stderr);

@@ -1608,7 +1627,7 @@

 void
 tar_usage(void)
 {
-	(void)fputs("usage: tar [-]{crtux}[-befhmopqsvwzHLMOPXZ014578] [blocksize] ",
+	(void)fputs("usage: tar [-]{crtux}[-befhjmopqsvwzHLMOPXZ014578] [blocksize] ",
 		 stderr);
 	(void)fputs("[archive] [replstr] [-C directory] [-I file] [file ...]\n",
 	    stderr);

@@ -1623,9 +1642,9 @@

 void
 cpio_usage(void)
 {
-	(void)fputs("usage: cpio -o [-aABcLMvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);
+	(void)fputs("usage: cpio -o [-aABcjLMvVzZ] [-C bytes] [-H format] [-O archive]\n", stderr);
 	(void)fputs("               [-F archive] < name-list [> archive]\n", stderr);
-	(void)fputs("       cpio -i [-bBcdfmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr);
+	(void)fputs("       cpio -i [-bBcdfjmnrsStuvVzZ6] [-C bytes] [-E file] [-H format]\n", stderr);
 	(void)fputs("               [-I archive] [-F archive] [pattern...] [< archive]\n", stderr);
 	(void)fputs("       cpio -p [-adlLmMuvV] destination-directory < name-list\n", stderr);
 	exit(1);
diff -Nur pax-3.3-modifyWarn/src/pax.1 pax-3.3-bzip2/src/pax.1
--- pax-3.3-modifyWarn/src/pax.1	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-bzip2/src/pax.1	2003-04-22 15:15:50.000000000 +1000

@@ -46,7 +46,7 @@
 .Nd read and write file archives and copy directory hierarchies
 .Sh SYNOPSIS
 .Nm pax
-.Op Fl cdnvz
+.Op Fl cdjnvz
 .Bk -words
 .Op Fl f Ar archive
 .Ek

@@ -73,7 +73,7 @@
 .Op Ar pattern ...
 .Nm pax
 .Fl r
-.Op Fl cdiknuvzDYZ
Can we help you?X
+.Op Fl cdijknuvzDYZ .Bk -words .Op Fl f Ar archive .Ek

@@ -109,7 +109,7 @@
 .Op Ar pattern ...
 .Nm pax
 .Fl w
-.Op Fl dituvzHLMPX
+.Op Fl dijtuvzHLMPX
 .Bk -words
 .Op Fl b Ar blocksize
 .Ek

@@ -467,6 +467,12 @@

 is encountered when reading a response or if  .Pa /dev/tty
 cannot be opened for reading and writing.
+.It Fl z
+Use
+.Xr bzip2 1
+to compress (decompress) the archive while writing (reading).
+Incompatible with
+.Fl a .

 .It Fl k
 Do not overwrite existing files.
 .It Fl l
@@ -1174,6 +1180,7 @@

 .St -p1003.2
 standard.
 The options
+.Fl j ,
 .Fl B ,
 .Fl D ,
 .Fl E ,
diff -Nur pax-3.3-modifyWarn/src/tar.1 pax-3.3-bzip2/src/tar.1
--- pax-3.3-modifyWarn/src/tar.1	2003-04-22 15:15:50.000000000 +1000
+++ pax-3.3-bzip2/src/tar.1	2003-04-22 15:15:50.000000000 +1000

@@ -39,7 +39,7 @@
 .Sh SYNOPSIS
 .Nm tar
 .Sm off
-.Oo \&- Oc {crtux} Op befhmopqsvwzHLMOPXZ014578
+.Oo \&- Oc {crtux} Op befhjmopqsvwzHLMOPXZ014578
 .Sm on
 .Op Ar blocksize
 .Op Ar archive

@@ -111,6 +111,10 @@

 In extract mode this means that a directory entry in the archive  will not overwrite an existing symbolic link, but rather what the  link ultimately points to.
+.It Fl j
+Compress or decompress archive using
+.Xr bzip2 1
+format.

 .It Fl m
 Do not preserve modification time.
 .It Fl O
@@ -194,7 +198,9 @@

 to prompt the user for the filename to use when storing or  extracting files in an archive.
 .It Fl z
-Compress archive using gzip.
+Compress or decompress archive using
+.Xr gzip 1
+format.

 .It Fl C Ar directory
 This is a positional argument which sets the working directory for the  following files.
@@ -333,6 +339,7 @@

 .At v7 .
 .Sh CAVEATS
 The
+.Fl j ,
 .Fl L
 and
 .Fl M
Call Pantek today for Open Source Technical Support at 1-877-546-8934 - 24/7/365X

This final patch fixes a couple of minor errors in the man page. It is similar to a Red Hat patch to pax.

diff -Nur pax-3.3.orig/src/pax.1 pax-3.3-doc/src/pax.1

--- pax-3.3.orig/src/pax.1	2003-03-13 06:12:35.000000000 +1000
+++ pax-3.3-doc/src/pax.1	2003-04-22 15:15:50.000000000 +1000

@@ -720,7 +720,7 @@
 .It Ar tar
 The old BSD tar format as found in BSD4.3.  The default blocksize for this format is 10240 bytes. -Pathnames stored by this format must be 100 characters or less in length. +Pathnames stored by this format must be 99 characters or less in length.  Only
 .Em regular
 files,
@@ -738,7 +738,9 @@

 .St -p1003.2
 standard.
 The default blocksize for this format is 10240 bytes. -Pathnames stored by this format must be 250 characters or less in length.
+Filenames stored by this format, not including the directory prefix, can
+not be more than 99 characters in length.  The directory prefix can not be
+more than 155 characters in length.
 .El

 .Pp
 .Nm
--
Regards,
Russell Stuart
Received on Tue Apr 22 01:57:18 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:54 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library