[comp.sys.sgi] Getting GNU Tar V1.07 running on SGI IRIS 4D

pwolfe@kailand.kai.com (Patrick Wolfe) (08/10/89)

> From: Dan Bucko Smith <uiucuxc!well!dansmith>
> 	Has anyone got gnutar working sucessfully on a 4D?  If so,
> would you mail me 1) how you did it, and 2) what version did you
> manage to do this with?

Enclosed in this shell archive are three files that can be used to get GNU Tar
V1.07 running on your SGI 4D machine (with IRIX V3.1D).  It might work on other
version of the operating systems and machines as well, I don't know.

I use GNU tar V1.07 for monthly full backups, and weekly incrementals on all
our System V machines, since our backup tape drives are all on BSD hosts.  On
the BSD hosts, I use GNU tar for weekly and daily incrementals as well, since
it can handle active file systems better than BSD's "dump" command, and I can
ignore "*.o" and "*.a" files.

I've also got GNU Make V3.54, GNU diff 1.07, and RCS V4.2 all running on our
IRIS's, just in case anyone's interested (Parallel Make is GREAT!).

	Enjoy!

	Patrick Wolfe  (pat@kai.com,  {uunet,sgi}!kailand!pat
	System Manager, Kuck & Associates, Inc.


====  cut here  =====  cut here  =====  cut here  =====  cut here  =====
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  SGI.Readme SGI.diffs alloca.c
# Wrapped by pwolfe@kailand on Wed Aug  9 16:37:59 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'SGI.Readme' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'SGI.Readme'\"
else
echo shar: Extracting \"'SGI.Readme'\" \(2167 characters\)
sed "s/^X//" >'SGI.Readme' <<'END_OF_FILE'
XEnclosed in this shell archive are three files that can be used to get GNU Tar
XV1.07 running on your SGI 4D machine (with IRIX V3.1D).  It might work on other
Xversion of the operating systems and machines as well, I don't know.
X
X	SGI.Readme	- this file
X	SGI.diffs	- some patches to four files
X	alloca.c	- public domain version of alloca()
X
X==================================================
X
XI picked up GNU tar V1.07 on July 17th, 1989 by anonymously ftp from
X	HOST:	prep.ai.mit.edu
X	DIR:	/pub/gnu
X	FILE:	tar-1.07.tar.Z
XDon't forget to set "binary" mode to receiving it!
X
X==================================================
X
X****  STEP 1  ****
XUnpack this shell archive.
X
XIf you have "unshar", just feed this file to it.
X
XIf you need to use the shell to unpack this archive, you will need to:
X	save this file (maybe as "SGI.patch01")
X	edit this file
X	delete the lines up to and including the "cut here" line
X	save and exit the editor
X	feed the file to the Bourne Shell, not C shell
X		(just enter "sh SGI.patch01")
X
X
X****  STEP 2  ****
XSave the old source.
X
XIf you use RCS, SCCS or some other source code revision control system, check
Xout and lock the files to be patched:
X	port.c
X	rtape_lib.c
X	rtape_server.c
X	Makefile
X
XIf you don't have one of these nifty utilities, just *copy* these files to
Xsome safe place, possible a new directory "./Old".
X
X
X****  STEP 3  ****
XPatch the three C source code files and the makefile.
X
XIf you have the "patch" program, just feed the file "SGI.diffs" to it.
X
XIf you don't have patch, you'll have to apply the patches by hand.  Don't worry, it
Xdoesn't take *too* long.
X
X
X****  STEP 4  ****
XCheck the "Makefile" to make sure everything is setup according to your site's
Xlocal conventions.
X
X
X****  STEP 5  ****
XRun "make".
X
XHopefully, everything will compile and link okay.
X
X
X==================================================
XWhen installing this, I suggest you save the old version of "/bin/tar" and
X"/etc/rmt", just in case something happens to be wrong in GNU tar, or some
Xobscure option of the original tar command is needed sometime.
X
XHope everything works out for you.
X
XPatrick Wolfe   (pat@kai.com,  {uunet,sgi}!kailand!pat)
X
END_OF_FILE
if test 2167 -ne `wc -c <'SGI.Readme'`; then
    echo shar: \"'SGI.Readme'\" unpacked with wrong size!
fi
# end of 'SGI.Readme'
fi
if test -f 'SGI.diffs' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'SGI.diffs'\"
else
echo shar: Extracting \"'SGI.diffs'\" \(4196 characters\)
sed "s/^X//" >'SGI.diffs' <<'END_OF_FILE'
XHere are patches for the following four files:
X	port.c
X	rtape_lib.c
X	rtape_server.c
X	Makefile
X
XI created these getting GNU Tar V1.07 compiled and running on our IRIS 4D's.
X
X
X*** /tmp/,RCSt1a09338	Wed Aug  9 15:40:05 1989
X--- port.c	Wed Aug  9 14:11:50 1989
X***************
X*** 42,48 ****
X  #include "tar.h"
X  #include "port.h"
X  
X! extern size_t strlen();
X  
X  extern long baserec;
X  /*
X--- 42,48 ----
X  #include "tar.h"
X  #include "port.h"
X  
X! /* extern size_t strlen(); */
X  
X  extern long baserec;
X  /*
X***************
X*** 88,93 ****
X--- 88,97 ----
X  #ifdef USG
X  #define WANT_STRING
X  #define WANT_VALLOC
X+ #ifdef sgi
X+ #define WANT_CK_PIPE
X+ #define WANT_STRSTR
X+ #endif /* sgi */
X  #endif
X  
X  #ifdef MINIX
X
X
X*** /tmp/,RCSt1008720	Wed Aug  9 16:15:01 1989
X--- rtape_lib.c	Wed Aug  9 16:14:01 1989
X***************
X*** 136,142 ****
X  char *buf;
X  {
X  	register int blen;
X! 	int (*pstat)();
X  
X  /*
X   *	save current pipe status and try to make the request
X--- 139,145 ----
X  char *buf;
X  {
X  	register int blen;
X! 	SIGTYPE (*pstat)();
X  
X  /*
X   *	save current pipe status and try to make the request
X***************
X*** 386,402 ****
X--- 389,415 ----
X  		(void) setgid (getgid ());
X  		if (*login)
X  		{
X+ #ifdef sgi
X+ 			execl("/usr/bsd/rsh", "rsh", system, "-l", login,
X+ 				"/etc/rmt", (char *) 0);
X+ #else
X  			execl("/usr/ucb/rsh", "rsh", system, "-l", login,
X  				"/etc/rmt", (char *) 0);
X  			execl("/usr/bin/remsh", "remsh", system, "-l", login,
X  				"/etc/rmt", (char *) 0);
X+ #endif
X  		}
X  		else
X  		{
X+ #ifdef sgi
X+ 			execl("/usr/bsd/rsh", "rsh", system,
X+ 				"/etc/rmt", (char *) 0);
X+ #else
X  			execl("/usr/ucb/rsh", "rsh", system,
X  				"/etc/rmt", (char *) 0);
X  			execl("/usr/bin/remsh", "remsh", system,
X  				"/etc/rmt", (char *) 0);
X+ #endif
X  		}
X  
X  /*
X***************
X*** 487,493 ****
X  unsigned int nbyte;
X  {
X  	char buffer[BUFMAGIC];
X! 	int (*pstat)();
X  
X  	sprintf(buffer, "W%d\n", nbyte);
X  	if (command(fildes, buffer) == -1)
X--- 500,506 ----
X  unsigned int nbyte;
X  {
X  	char buffer[BUFMAGIC];
X! 	SIGTYPE (*pstat)();
X  
X  	sprintf(buffer, "W%d\n", nbyte);
X  	if (command(fildes, buffer) == -1)
X
X
X*** /tmp/,RCSt1a09338	Wed Aug  9 15:40:04 1989
X--- rtape_server.c	Wed Aug  9 14:20:05 1989
X***************
X*** 48,54 ****
X  char	count[SSIZE], mode[SSIZE], pos[SSIZE], op[SSIZE];
X  
X  extern	errno;
X! char	*sys_errlist[];
X  char	resp[BUFSIZ];
X  
X  long	lseek();
X--- 48,54 ----
X  char	count[SSIZE], mode[SSIZE], pos[SSIZE], op[SSIZE];
X  
X  extern	errno;
X! extern	char	*sys_errlist[];
X  char	resp[BUFSIZ];
X  
X  long	lseek();
X
X
X*** /tmp/,RCSt1008836	Wed Aug  9 16:19:53 1989
X--- Makefile	Wed Aug  9 16:19:37 1989
X***************
X*** 14,27 ****
X  #O = o
X  
X  # Berserkeley version
X! DEFS = -DBSD42
X! LOCAL_SRC = getdate.y  rtape_lib.c
X! LOCAL_OBJ = getdate.$O rtape_lib.$O
X  LDFLAGS =
X! LIBS =
X  LINT = lint
X! LINTFLAGS = -abchx
X! DEF_AR_FILE = \"/dev/rmt8\"
X  DEFBLOCKING = 20
X  O = o
X  
X--- 14,42 ----
X  #O = o
X  
X  # Berserkeley version
X! # for 4.3
X! #DEFS = -DBSD42 -DSIGTYPE=void
X! # for 4.2
X! #DEFS = -DBSD42 -DSIGTYPE=int
X! #LOCAL_SRC = getdate.y  rtape_lib.c
X! #LOCAL_OBJ = getdate.$O rtape_lib.$O
X! #LDFLAGS =
X! #LIBS =
X! #LINT = lint
X! #LINTFLAGS = -abchx
X! #DEF_AR_FILE = \"/dev/rmt8\"
X! #DEFBLOCKING = 20
X! #O = o
X! 
X! # SGI IRIX 3.1D version
X! DEFS = -DUSG -DSIGTYPE=void -I/usr/include/bsd
X! LOCAL_SRC =  getdate.y rtape_lib.c alloca.c
X! LOCAL_OBJ =  getdate.$O rtape_lib.$O alloca.$O
X  LDFLAGS =
X! LIBS = -lPW -lbsd
X  LINT = lint
X! LINTFLAGS = -p
X! DEF_AR_FILE = \"/dev/tape\"
X  DEFBLOCKING = 20
X  O = o
X  
X***************
X*** 128,136 ****
X  	-DDEF_AR_FILE=$(DEF_AR_FILE) \
X  	-DDEFBLOCKING=$(DEFBLOCKING)
X  # next line for Debugging
X! COPTS = -g
X  # next line for Production
X! #COPTS = -O
X  
X  # Add things here like getopt, readdir, etc that aren't in your
X  # standard libraries.  (E.g. MSDOS needs getopt, msd_dir.c, msd_dir.obj)
X--- 143,151 ----
X  	-DDEF_AR_FILE=$(DEF_AR_FILE) \
X  	-DDEFBLOCKING=$(DEFBLOCKING)
X  # next line for Debugging
X! #COPTS = -g
X  # next line for Production
X! COPTS = -O
X  
X  # Add things here like getopt, readdir, etc that aren't in your
X  # standard libraries.  (E.g. MSDOS needs getopt, msd_dir.c, msd_dir.obj)
END_OF_FILE
if test 4196 -ne `wc -c <'SGI.diffs'`; then
    echo shar: \"'SGI.diffs'\" unpacked with wrong size!
fi
# end of 'SGI.diffs'
fi
if test -f 'alloca.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'alloca.c'\"
else
echo shar: Extracting \"'alloca.c'\" \(4743 characters\)
sed "s/^X//" >'alloca.c' <<'END_OF_FILE'
X/*
X	alloca -- (mostly) portable public-domain implementation -- D A Gwyn
X
X	This implementation of the PWB library alloca() function,
X	which is used to allocate space off the run-time stack so
X	that it is automatically reclaimed upon procedure exit, 
X	was inspired by discussions with J. Q. Johnson of Cornell.
X
X	It should work under any C implementation that uses an
X	actual procedure stack (as opposed to a linked list of
X	frames).  There are some preprocessor constants that can
X	be defined when compiling for your specific system, for
X	improved efficiency; however, the defaults should be okay.
X
X	The general concept of this implementation is to keep
X	track of all alloca()-allocated blocks, and reclaim any
X	that are found to be deeper in the stack than the current
X	invocation.  This heuristic does not reclaim storage as
X	soon as it becomes invalid, but it will do so eventually.
X
X	As a special case, alloca(0) reclaims storage without
X	allocating any.  It is a good idea to use alloca(0) in
X	your main control loop, etc. to force garbage collection.
X*/
X#ifndef lint
Xstatic char	SCCSid[] = "@(#)alloca.c	1.1";	/* for the "what" utility */
X#endif
X
X#ifdef X3J11
Xtypedef void	*pointer;		/* generic pointer type */
X#else
Xtypedef char	*pointer;		/* generic pointer type */
X#endif
X
X#define	NULL	0			/* null pointer constant */
X
Xextern void	free();
Xextern pointer	malloc();
X
X/*
X	Define STACK_DIRECTION if you know the direction of stack
X	growth for your system; otherwise it will be automatically
X	deduced at run-time.
X
X	STACK_DIRECTION > 0 => grows toward higher addresses
X	STACK_DIRECTION < 0 => grows toward lower addresses
X	STACK_DIRECTION = 0 => direction of growth unknown
X*/
X
X#ifndef STACK_DIRECTION
X#define	STACK_DIRECTION	0		/* direction unknown */
X#endif
X
X#if STACK_DIRECTION != 0
X
X#define	STACK_DIR	STACK_DIRECTION	/* known at compile-time */
X
X#else	/* STACK_DIRECTION == 0; need run-time code */
X
Xstatic int	stack_dir;		/* 1 or -1 once known */
X#define	STACK_DIR	stack_dir
X
Xstatic void
Xfind_stack_direction (/* void */)
X{
X  static char	*addr = NULL;	/* address of first
X				   `dummy', once known */
X  auto char	dummy;		/* to get stack address */
X
X  if (addr == NULL)
X    {				/* initial entry */
X      addr = &dummy;
X
X      find_stack_direction ();	/* recurse once */
X    }
X  else				/* second entry */
X    if (&dummy > addr)
X      stack_dir = 1;		/* stack grew upward */
X    else
X      stack_dir = -1;		/* stack grew downward */
X}
X
X#endif	/* STACK_DIRECTION == 0 */
X
X/*
X	An "alloca header" is used to:
X	(a) chain together all alloca()ed blocks;
X	(b) keep track of stack depth.
X
X	It is very important that sizeof(header) agree with malloc()
X	alignment chunk size.  The following default should work okay.
X*/
X
X#ifndef	ALIGN_SIZE
X#define	ALIGN_SIZE	sizeof(double)
X#endif
X
Xtypedef union hdr
X{
X  char	align[ALIGN_SIZE];	/* to force sizeof(header) */
X  struct
X    {
X      union hdr *next;		/* for chaining headers */
X      char *deep;		/* for stack depth measure */
X    } h;
X} header;
X
X/*
X	alloca( size ) returns a pointer to at least `size' bytes of
X	storage which will be automatically reclaimed upon exit from
X	the procedure that called alloca().  Originally, this space
X	was supposed to be taken from the current stack frame of the
X	caller, but that method cannot be made to work for some
X	implementations of C, for example under Gould's UTX/32.
X*/
X
Xstatic header *last_alloca_header = NULL; /* -> last alloca header */
X
Xpointer
Xalloca (size)			/* returns pointer to storage */
X     unsigned	size;		/* # bytes to allocate */
X{
X  auto char	probe;		/* probes stack depth: */
X  register char	*depth = &probe;
X
X#if STACK_DIRECTION == 0
X  if (STACK_DIR == 0)		/* unknown growth direction */
X    find_stack_direction ();
X#endif
X
X				/* Reclaim garbage, defined as all alloca()ed storage that
X				   was allocated from deeper in the stack than currently. */
X
X  {
X    register header	*hp;	/* traverses linked list */
X
X    for (hp = last_alloca_header; hp != NULL;)
X      if (STACK_DIR > 0 && hp->h.deep > depth
X	  || STACK_DIR < 0 && hp->h.deep < depth)
X	{
X	  register header	*np = hp->h.next;
X
X	  free ((pointer) hp);	/* collect garbage */
X
X	  hp = np;		/* -> next header */
X	}
X      else
X	break;			/* rest are not deeper */
X
X    last_alloca_header = hp;	/* -> last valid storage */
X  }
X
X  if (size == 0)
X    return NULL;		/* no allocation required */
X
X  /* Allocate combined header + user data storage. */
X
X  {
X    register pointer	new = malloc (sizeof (header) + size);
X    /* address of header */
X
X    ((header *)new)->h.next = last_alloca_header;
X    ((header *)new)->h.deep = depth;
X
X    last_alloca_header = (header *)new;
X
X    /* User storage begins just after header. */
X
X    return (pointer)((char *)new + sizeof(header));
X  }
X}
X
END_OF_FILE
if test 4743 -ne `wc -c <'alloca.c'`; then
    echo shar: \"'alloca.c'\" unpacked with wrong size!
fi
# end of 'alloca.c'
fi
echo shar: End of shell archive.
exit 0



-- 

        Patrick Wolfe   (pat@kai.com, kailand!pat)
        System Manager, Kuck & Associates, Inc.