From: bboerner@novdpd.uucp (Brendan B. Boerner)
Newsgroups: comp.os.linux
Subject: patch to Pax v1.2
Date: 15 Sep 92 13:52:31 GMT
Organization: Novell, Inc. --Austin

Hello,

Has anyone used pax to write multiple floppy archives?  I'm using 0.97
Pl 5 kernel with a system built using Jim Winstead's boot/root disk set
and am trying this:

$ pax -w -v -f /dev/fd0 <some stuff>

(also tried /dev/fd0h1200 and /dev/fd0d360 on a 360K disk).  The floppy
runs for a while and then stops and nothing happens.  Data is getting
written because I can do a pax -v -f /dev/fd0 and read the archive - it
gets to the end and asks for the next volume.

I got the source from ftp.uu.net and poked around and found that in the
function outflush(), something like this is written:

for (...) {
	if ((got = write(...)) > 0) {
		...
	} else if (got < 0) {
		next archive
	}
}

The problem is that the last write to the floppy returns 0 so this just
loops forever.  I checked out write(2) and it did say that write/read
will return 0 on EOF sooooo.... what's different?  Did the defined
return value for write() change since pax was written?

I've enclosed a patch which will take Pax v1.2 and modify config.h,
buffer.c and pax.h so that it will compile under Linux with GCC
v2.2.2d.

Later,
Brendan
-- 
Brendan B. Boerner		Phone: 512/346-8380
Internet: bboerner@novell.com	MHS: bboerner@novell
Please use ^^^^^^^^^^^^^^^^^ if replying by mail.


This is a patch for Pax v1.2 for Linux and fixes one bug.  To get
Pax source, get it from
ftp.uu.net:archive/usenet/comp.sources.unix/volume17/pax.  Apply the
three patchs that are in that directory before applying this patch.

Brendan
bboerner@novell.com
92/09/15

diff +unified pax/buffer.c pax.lin/buffer.c
--- pax/buffer.c	Mon Sep 14 22:27:28 1992
+++ pax.lin/buffer.c	Mon Sep 14 22:00:15 1992
@@ -115,7 +115,11 @@
     Link           *linkp;
     int             ifd;
     int             ofd;
+#ifdef LINUX
+    struct utimbuf  tstamp;
+#else
     time_t          tstamp[2];
+#endif
 
     if ((ofd = openout(name, asb, linkp = linkfrom(name, asb), 0)) > 0) {
 	if (asb->sb_size || linkp == (Link *)NULL || linkp->l_size == 0) {
@@ -130,9 +134,15 @@
     } else {
 	return(buf_skip((OFFSET) asb->sb_size) >= 0);
     }
+#ifdef LINUX
+    tstamp.actime = (!f_pass && f_access_time) ? asb->sb_atime : time((time_t *) 0);
+    tstamp.modtime = f_mtime ? asb->sb_mtime : time((time_t *) 0);
+    utime(name, &tstamp);
+#else
     tstamp[0] = (!f_pass && f_access_time) ? asb->sb_atime : time((time_t *) 0);
     tstamp[1] = f_mtime ? asb->sb_mtime : time((time_t *) 0);
     utime(name, tstamp);
+#endif
     return (0);
 }
 
@@ -583,7 +593,7 @@
 	for (buf = bufstart; len = bufidx - buf;) {
 	    if ((got = write(archivefd, buf, MIN(len, blocksize))) > 0) {
 		buf += got;
-	    } else if (got < 0) {
+	    } else if (got <= 0) {
 		next(AR_WRITE);
 	    }
 	}
diff +unified pax/config.h pax.lin/config.h
--- pax/config.h	Mon Sep 14 22:27:28 1992
+++ pax.lin/config.h	Mon Sep 14 22:18:08 1992
@@ -45,7 +45,7 @@
  * Defining XENIX_286 will automatically define USG.
  *
  */
-#define XENIX_286	/* Running on a XENIX 286 system */
+/* #define XENIX_286	/* Running on a XENIX 286 system */
 
 /*
  * USG - USG (Unix System V) specific modifications
@@ -52,9 +52,16 @@
  *
  * Define USG if you are running Unix System V or some similar variant
  */
-#define USG 	/* Running on a USG System */
+/* #define USG 	/* Running on a USG System */
 
 /*
+ * LINUX - Linux v0.97
+ *
+ * Also define BSD.
+ */
+#define LINUX	/* Running on a Linux system */
+
+/*
  * BSD - BSD (Berkely) specific modifications
  *
  * Define BSD if you are running some version of BSD Unix
@@ -128,8 +135,8 @@
  * Some systems have signal defines to return an int *, other return a
  * void *.  Please choose the correct value for your system.
  */
-/* #define SIG_T	void	/* signal defined as "void (*signal)()" */
-#define SIG_T	int	/* signal defined as "int (*signal)()" */
+#define SIG_T	void	/* signal defined as "void (*signal)()" */
+/* #define SIG_T	int	/* signal defined as "int (*signal)()" */
 
 /*
  * STRCSPN - use the strcspn function included with pax
@@ -147,7 +154,7 @@
  * For those system define STRERROR and the one provided in misc.c will 
  * be used instead.
  */
-#define STRERROR	/* implementation does not have strerror() */
+/* #define STRERROR	/* implementation does not have strerror() */
 
 /*
 
@@ -176,3 +183,4 @@
 #endif /* XENIX_286 */
 
 #endif /* _PAX_CONFIG_H */
+
diff +unified pax/pax.h pax.lin/pax.h
--- pax/pax.h	Mon Sep 14 22:27:30 1992
+++ pax.lin/pax.h	Mon Sep 14 18:19:50 1992
@@ -41,6 +41,9 @@
 #include <errno.h>
 #include <signal.h>
 #include <ctype.h>
+#ifdef LINUX
+#include <utime.h>
+#endif
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -361,7 +364,7 @@
 extern char    *optarg;
 extern int      optind;
 extern int      sys_nerr;
-extern char    *sys_errlist[];
+/* extern char    *sys_errlist[]; */
 extern int      errno;
 
 #endif /* _PAX_H */
diff +unified pax/port.h pax.lin/port.h
--- pax/port.h	Mon Sep 14 22:27:32 1992
+++ pax.lin/port.h	Mon Sep 14 17:52:27 1992
@@ -70,7 +70,7 @@
 extern char *bcopy(char *, char *, unsigned int);
 extern char *bzero(char *, unsigned int);
 extern char *strcat(char *, char *);
-extern char *strcpy(char *, char *);
+/* extern char *strcpy(char *, char *); */
 #  else /* !__STDC__ */
 extern char *rindex();
 extern char *index();