|
|
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);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.