File:  [Research Unix] / researchv9 / sys / boot / stand / copy.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:59 2018 UTC (8 years, 3 months ago) by root
Branches: belllabs, MAIN
CVS tags: researchv9-SUN3_old, researchv9-SUN3, HEAD
researchv9-SUN3(old)

#ifndef lint
static	char sccsid[] = "@(#)copy.c	1.1 86/02/03	SMI"; /* From ancient history */
#endif

#define	BUFSIZ	(3*10*1024)	/* must be multiple of 10K, < 32K */

/*
 * Copy from to in large units.
 * Intended for use in bootstrap procedure.
 */
main()
{
	int from, to;
	char fbuf[50], tbuf[50];
	static char buffer[BUFSIZ];
	register int i;
	register int count = 0;

	printf("Standalone Copy\n");
	from = getdev("From", fbuf, 0);
	to = getdev("To", tbuf, 1);
	for (;;) {
		i = read(from, buffer, sizeof (buffer));
		if (i <= 0)
			break;
		if (write(to, buffer, i) != i) {
			printf("Write error\n");
			break;
		}
		count += i;
	}
	if (i < 0)
		printf("Read error\n");
	printf("Copy completed - %d bytes\n", count);
}

getdev(prompt, buf, mode)
	char *prompt, *buf;
	int mode;
{
	register int i;

	do {
		printf("%s: ", prompt);
		gets(buf);
		i = open(buf, mode);
	} while (i <= 0);
	return (i);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.