[net.bugs.4bsd] Need cpio.c source

pete@ecrcvax.UUCP (Pete Delaney) (04/26/85)

	Sigh.  For some strange reason Berkely 4.2 doesn't come with
SCCS or cpio.  These turkeys makeing releases should get their sh*t
together!  Would someone out there in net land please send a copy of
the new System V cpio so we can read our release tape so that we can
get the source of SCCS, so that we can use the latest kernel.

	SUMMARY:
		Please send a copy oc cpio.c that supports the 
		new ASCII headers (ie: the -c option).  If any
		other library functions not found in System 5
		are required please send them also.  I would
		prefer a copy already running on 4.2BSD.
-- 
Pete Delaney - Rockey Mnt UNIX Consultant 	Phone: (49) 89 9269-139
European Computer-Industry Research Center 	UUCP: mcvax!unido!ecrcvax!pete
ArabellaStrasse 17 				UUCP Domain: pete@ecrcvax.UUCP
D-8000 Muenchen 81, West Germany 		X25: (262)-45890040262
CSNET:pete%ecrcvax.UUCP@Germany.CSNET		     Login: <to be provided?>

mark@cbosgd.UUCP (Mark Horton) (04/28/85)

In article <55@ecrcvax.UUCP> pete@ecrcvax.UUCP (Pete Delaney) writes:
>
>	Sigh.  For some strange reason Berkely 4.2 doesn't come with
>SCCS or cpio.  These turkeys makeing releases should get their sh*t
>together!  Would someone out there in net land please send a copy of
>the new System V cpio so we can read our release tape so that we can
>get the source of SCCS, so that we can use the latest kernel.

I feel obligated to point out the reason why 4.2BSD does not include
cpio or SCCS.  If they did, AT&T would be justified in legal action
to stop them from distributing 4.2BSD at all.  Contrary to a comment
I just read here, 4.2BSD requires a UNIX/32V license, NOT a System V
license.  This means that Berkeley can include AT&T code that was
in UNIX/32V, but they do not have permission from AT&T to include
code from other AT&T versions of UNIX.

In particular, cpio and SCCS were both in PWB/UNIX 1.0, in System III,
and in System V, but not in V7 or 32V.  So it would be illegal for
Berkeley to include them in their system unless they required one
of these licenses from everyone they distribute UNIX to.

Before anyone sends a copy to ecrcvax, you'd best verify that ecrcvax
has a System V license.  Otherwise you'll be violating your license.

Incidently, while the V7/nBSD family does not have cpio, they do have
tar, a similar program.  Since System III and System V have tar (except
for the 3B2, which for some reason left it out) it has emerged that
the only universal complete file packaging format for UNIX is tar format,
for tapes and for UUCP images.  Apparently for this reason, /usr/group
has adopted tar format as part of the UNIX standard.

guy@sun.uucp (Guy Harris) (04/30/85)

> 
> 	Sigh.  For some strange reason Berkely 4.2 doesn't come with
> SCCS or cpio.  These turkeys makeing releases should get their sh*t
> together!

The "strange reason" is called "AT&T licensing requirements".  SCCS and
"cpio" both require System V source licenses; 4.2BSD does not require such a
license.  The University of California would have plenty of deep legal sh*t
already gotten together for their benefit by AT&T if they offered either
SCCS or "cpio" with 4.2BSD.

	Guy Harris

gnu@sun.uucp (John Gilmore) (04/30/85)

You can always dd the whole tape into a file and search for the cpio sources
within the tape image.  I believe SysV cpio doesn't instantly work on 4.2
but it's not hard to fix.

Now wouldn't it have been nice if Sys V source tapes put cpio.c on the front?
(As the first file dumped in the cpio file containing all the sources.)

Of course if they'd wanted to be really nice they'd have used tar instead...

ron@celerity.UUCP (Ron McDaniels) (05/01/85)

In article <55@ecrcvax.UUCP> pete@ecrcvax.UUCP (Pete Delaney) writes:
>
>	Sigh.  For some strange reason Berkely 4.2 doesn't come with
>SCCS or cpio.  These turkeys makeing releases should get their sh*t
>together!  Would someone out there in net land please send a copy of
>the new System V cpio so we can read our release tape so that we can
>get the source of SCCS, so that we can use the latest kernel.
>
>	SUMMARY:
>		Please send a copy oc cpio.c that supports the 
>		new ASCII headers (ie: the -c option).  If any
>		other library functions not found in System 5
>		are required please send them also.  I would
>		prefer a copy already running on 4.2BSD.
>-- 
>Pete Delaney - Rockey Mnt UNIX Consultant 	Phone: (49) 89 9269-139
>European Computer-Industry Research Center 	UUCP: mcvax!unido!ecrcvax!pete
>ArabellaStrasse 17 				UUCP Domain: pete@ecrcvax.UUCP
>D-8000 Muenchen 81, West Germany 		X25: (262)-45890040262
>CSNET:pete%ecrcvax.UUCP@Germany.CSNET		     Login: <to be provided?>

Hay, while you're at it, please run me off a copy of the sys 5 release tape!
Hope you don't mind sending it to my home address. . .

McD

keld@diku.UUCP (Keld J|rn Simonsen) (05/02/85)

cpio is part of the UNIX/1100 system for Sperry 1100 machines,
which is a Version 7 licence. Well, so reads my academic source
license! So you can get cpio for V7, but not for 32V!
32V does not give you the right to copy from V7, this "previous
systems" copying is only in S3 and after.

lmc@denelcor.UUCP (Lyle McElhaney) (05/02/85)

> You can always dd the whole tape into a file and search for the cpio sources
> within the tape image.  I believe SysV cpio doesn't instantly work on 4.2
> but it's not hard to fix.
> 
The only thing that required changing was the removal to two references
to multiplexed files. After that it compiles and seems to work fine.
-- 
Lyle McElhaney
{hao, stcvax, brl-bmd, nbires, csu-cs} !denelcor!lmc

pete@ecrcvax.UUCP (Pete Delaney) (05/02/85)

I am Sorry for my succinctly stating my displeasure with release proceedures.
I meant that the Sys5 release, not the 4.2BSD release, could have been released
in a nicer form.  ATT no longer had the 'not in the computer business'
restriction to stop them from makeing extraction and porting of their code easy.
The enclusion of the source for the program to remove the sources should have
been a file that could be extracted with dd; like USENIX and perhaps 4.2bsd.

Sorry, for the misunderstanding.
-- 

--------------------------------------------
Pete Delaney - Rocky Mnt. Unix Consultant	Phone: (49) 89 9269-139
European Computer-Industry Research Center 	UUCP: mcvax!unido!ecrcvax!pete
ArabellaStrasse 17 				UUCP Domain: pete@ecrcvax.UUCP
D-8000 Muenchen 81, West Germany 		X25: (262)-45890040262
CSNET:pete%ecrcvax.UUCP@Germany.CSNET		     Login: <to be provided?>
------------------------------------------------------------------------------

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (05/02/85)

> > You can always dd the whole tape into a file and search for the cpio sources
> > within the tape image.  I believe SysV cpio doesn't instantly work on 4.2
> > but it's not hard to fix.
> > 
> The only thing that required changing was the removal to two references
> to multiplexed files. After that it compiles and seems to work fine.

Appearance can be deceiving!  You now have "utime" bugs in your CPIO,
along with several more subtle ones.

bzs@bu-cs.UUCP (Barry Shein) (05/06/85)

The following is a hack I threw together to bootstrap cpio.c
off of my SYSV tape. It only reads cpio tapes (hence the name, cpi).

As I said, it's a hack but all the hard work is done and you can
have it....

	-Barry Shein, Boston University

------------
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
/*
 *	cpi.c - read a cpio tape
 *		usage: cpi prefix
 *	will read in and create all files (and dirs) that
 *	match the prefix, for example 'cpi src/cmd' will
 *	read in src/cmd/foo.c src/cmd/thing/goo.c etc.
 *	TODO-
 *		cmd line: add tape drive, blksize,word/byte swap
 *			maybe more sophisticated selection of files
 *		doesn't check for TRAILER record at end of tape,
 *		just gives an error message and gives up
 *
 *	Look, this was a hack to get cpio.c off of a SYSV tape.
 *	It could use some cosmetics but all the hard work is done.
 *
 *	(C) Barry Shein, Boston University
 *	You have the right to distribute this to whomever you
 *	like as long as you don't remove my name so I can become
 *	famous for adding yet another unsupportable hack to the UNIX
 *	environment. If you give this away, give it with source, please.
 */
FILE *fcreat() ;
struct cpio {
	short	h_magic,
		h_dev;
	ushort	h_ino,
		h_mode,
		h_uid,
		h_gid;
	ushort	h_nlink,
		h_rdev,
		h_mtime[2],
		h_namesize,
		h_filesize[2] ;
} ;

#define BSIZE 5120		/* oughta be settable from cmd line */
char fbuf[BSIZE], *fbufp ;
int fbufk = 0 ;
#define MAXNAME	256		/* actually a cpio limit	*/
#define DEFTAPE "/dev/rmt0"	/* oughta be settable from cmd line */
main(argc,argv) int argc ; char **argv ;
{
	struct cpio cpio ;
	char namebuf[MAXNAME] ;
	char buf[BSIZE] ;
	register short *sip ;
	int fd ;
	int siz ;
	int i,j ;
	int *ip ;
	int fsize ;
	char *prfx ;
	int prfxl ;
	FILE *fp ;

	if(argc != 2) exit(printf("usage: %s prefix\n",*argv)) ;
	if((fd = open(DEFTAPE,0)) < 0)
		exit(perror(DEFTAPE)) ;
	prfx = argv[1] ;
	prfxl = strlen(prfx) ;
	siz = sizeof(cpio) ;
again:
	cread(fd,&cpio,siz) ;
#ifdef notdef			/* 3B5 needed byte swapping	*/
	swabw(&cpio,siz/2) ;
	printf("MAGIC: %07o\tUID: %6d\n",cpio.h_magic,
		cpio.h_uid) ;
#endif
	/* rebuild the long, if you re-declare as long alignment gets ya */
	fsize = (cpio.h_filesize[0] << 16) | cpio.h_filesize[1] ;
#ifdef notdef
	printf("NSIZE: %8d\tFSIZE: %8d\n",cpio.h_namesize,fsize) ;
#endif
	/* this is also what you will hear on end-of-tape */
	if((cpio.h_namesize < 0) || (cpio.h_namesize > MAXNAME))
	{
		printf("ridiculous name, giving up\n") ;
		printf("(fbufk = %d)\n",fbufk) ;
		exit(1) ;
	}
	/* NOTE: rounded up to even, will be padded on tape */
	i = (cpio.h_namesize & 01) ? cpio.h_namesize + 1 : cpio.h_namesize ;
	cread(fd,namebuf,i) ;
/*	printf("NAME: %s\n",namebuf) ;*/
	j = fsize ;
	if((j > 0) && (strncmp(namebuf,prfx,prfxl) == 0))
	{
		if((fp = fcreat(namebuf)) == NULL)
			perror(namebuf) ;
		else printf("%s\n",namebuf) ;	/* always 'verbose' */
	}
	else fp = NULL ;
	while(j > 0)
	{
		/* read in BSIZE pieces */
		if((i = cread(fd,buf,(j >= BSIZE) ? BSIZE : j)) <= 0)
		{
			printf("Error reading tape? (%s)\n",namebuf) ;
			exit(1) ;
		}
		j -= i ;
		/* see, I already had fcreat() from another thing I wrote */
		/* really shoulda made it not stdio but who cares	*/
		if(fp != NULL) write(fileno(fp),buf,i) ;
	}
	if(fp != NULL) fclose(fp) ;
	if(fsize & 1) cread(fd,buf,1) ;	/* get pad byte */
	goto again ;
}

/* buffered read */
cread(fd,bp,n) int fd ; register char *bp ; register int n ;
{
	int nb = 0 ;

	while(n--)
	{
		if(fbufk <= 0)
			if((fbufk = read(fd,fbufp = fbuf,BSIZE)) <= 0)
				return(nb) ;
		*bp++ = *fbufp++ ;
		--fbufk ;
		nb++ ;
	}
	return(nb) ;
}
wswab(i) int i ;
{
	return(((i & 0xff00) >> 8) | ((i & 0xff) << 8)) ;
}
swabw(sip,l) register short int *sip ; register int l ;
{
	while(l--) *sip++ = wswab(*sip) ;
}
/*
 *	bit of craziness to create output file. Will
 *	attempt to create all intervening path names.
 *	you're gonna need a mkdir() routine.
 */
FILE *
fcreat(path) char *path ;
{
	char buf[BUFSIZ] ;
	register char *bp ;

	strcpy(buf,path) ;
	bp = &buf[strlen(buf) - 1] ;
	while((*bp != '/') && (bp >= &buf[0]))
		bp-- ;
	if(*bp != '/') return(NULL) ;
	*bp = '\0' ;
	if(access(buf,F_OK) < 0)
	{
		char c ;

		for(bp = buf ;; bp++)
		{
			if((c = *bp) && (*bp != '/')) continue ;
			*bp = '\0' ;
			if(access(buf,F_OK) < 0)
				if(mkdir(buf,0777) < 0) return(NULL) ;
			if(c == '\0') break ;
			*bp = '/' ;
		}
	}
	return(fopen(path,"w")) ;
}

larry@anasazi.UUCP (Larry Rodis) (05/07/85)

> > 
> > 	Sigh.  For some strange reason Berkely 4.2 doesn't come with
> > SCCS or cpio.  These turkeys makeing releases should get their sh*t
> > together!
> 
> The "strange reason" is called "AT&T licensing requirements".  SCCS and
> "cpio" both require System V source licenses; 4.2BSD does not require such a
> license.  The University of California would have plenty of deep legal sh*t
> already gotten together for their benefit by AT&T if they offered either
> SCCS or "cpio" with 4.2BSD.
> 
> 	Guy Harris

You can by the source to SCCS and I believe that it does not a AT&T source 
licence. If I remeber correctly it costs about $2000 for source.  You can
find out more information on it by looking in the ULTRIX software applications
book.  This book is a compilation of software that will run on different
UNIX(tm) based systems.

-- 
Larry Rodis

UUCP: {decvax|ihnp4|hao}!noao!terak!anasazi!larry
                      ucbvax!asuvax!anasazi!larry
PHONE: +1 (602)275-0302

pete@ecrcvax.UUCP (Pete Delaney) (05/07/85)

I got the cpio and SCCS get stuff, thanks.  If anyone else needs a copy I'll
forwward you a copy (Assuming you have the right licenceses, of course).
I suppose it can't be posted to net.sources, unfortunately.
-- 

--------------------------------------------
Pete Delaney - Rocky Mnt. Unix Consultant	Phone: (49) 89 92699-139
European Computer-Industry Research Center 	UUCP: mcvax!unido!ecrcvax!pete
ArabellaStrasse 17 				UUCP Domain: pete@ecrcvax.UUCP
D-8000 Muenchen 81, West Germany 		X25: (262)-45890040262
CSNET:pete%ecrcvax.UUCP@Germany.CSNET		     Login: <to be provided?>
------------------------------------------------------------------------------