Subject: Re: copying boot tapes
To: Daniel Senderowicz <daniel@synchrods.synchrods.COM>
From: Paul A Vixie <paul@vix.com>
List: port-vax
Date: 02/17/1996 15:55:39
> I was wondering if somebody can tell me how to copy TK50 boot
> tapes using an Ultrix system. Thanks,

the program below if coupled with "dd" and a smart system programmer
will help you do what you want.

/* tapeanal.c - analyze a tape!
 * vix 26jan95 [boosted BUFSIZ]
 * vix 15sep88 [added multifile]
 * vix 24may88 [written]
 */

#include <stdio.h>

#define STDIN	0
#define MAXBUF	1024*1024

char buf[MAXBUF];
int grab = 0, fn = 0;
int outfd = -1;

main(argc, argv)
	int argc;
	char **argv;
{
	if (argc == 1)
		;
	else if (argc == 2) {
		grab++;
		printf("grabbing.\n");
	} else {
		printf("usage:  tapeanal [grab]\n");
		exit(1);
	}

	while (blocks(STDIN))
		;
}

blocks(f)
register f;
{
	register count, size, s;

	fn++;
	printf("#%d: ", fn); fflush(stdout);

	if (grab) {
		if (outfd != -1) close(outfd);
		sprintf(buf, "tapefile%04d", fn);
		outfd = creat(buf, 0666);
		if (outfd < 0) {perror(buf); exit(1);}
	}

	for (count = size = 0;  0 < (s = read(f, buf, MAXBUF));  count++) {
		if (grab) write(outfd, buf, s);
		if (s != size) {
			if (count > 0) printf("*%d ", count);
			size = s;
			count = 0;
			printf("%d", size); fflush(stdout);
		}
	}
	if (s == -1) perror("read");
	if (count > 0) printf("*%d ", count);
	printf("eof\n");
	return count;
}