X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/4fb3673cfc5d5ace662280ea005ae37130c7ce57..0cc0777f661116576a286d1d644dd0338074d41c:/usr/src/sys/stand.att/copy.c diff --git a/usr/src/sys/stand.att/copy.c b/usr/src/sys/stand.att/copy.c index e354ed396b..faead5bb5f 100644 --- a/usr/src/sys/stand.att/copy.c +++ b/usr/src/sys/stand.att/copy.c @@ -1,39 +1,54 @@ -/* copy.c 4.1 83/02/13 */ +/* + * Copyright (c) 1982, 1986, 1988 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + * + * @(#)copy.c 7.5 (Berkeley) %G% + */ + +#define BSIZE 10240 /* - * Copy from to in 10K units. - * Intended for use in system - * installation. + * Copy from from to to. Intended for use in system installation. */ main() { - int from, to; - char fbuf[50], tbuf[50]; - char buffer[10240]; - register int i; + extern int errno; + register int from, to, record, rcc, wcc; + char buf[BSIZE]; - from = getdev("From", fbuf, 0); - to = getdev("To", tbuf, 1); - for (;;) { - i = read(from, buffer, sizeof (buffer)); - if (i != sizeof (buffer)) + from = getfile("From", 0); + to = getfile("To", 1); + for (record = 0;; ++record) { + if (!(rcc = read(from, buf, BSIZE))) + break; + if (rcc < 0) { + printf("Record %d: read error, errno=%d\n", + record, errno); + break; + } + if (!record && rcc != BSIZE) { + rcc = BSIZE; + printf("Block size set from input; %d bytes\n", BSIZE); + } + if (rcc < BSIZE) + printf("Record %d: read short; expected %d, got %d\n", + record, BSIZE, rcc); +#ifdef vax + /* For bug in ht driver. */ + if (rcc > BSIZE) + rcc = BSIZE; +#endif + if ((wcc = write(to, buf, rcc)) < 0) { + printf("Record %d: write error: errno=%d\n", + record, errno); break; - (void) write(to, buffer, i); + } + if (wcc < rcc) { + printf("Record %d: write short; expected %d, got %d\n", + record, rcc, wcc); + break; + } } - printf("Copy completed\n"); - /* can't call exit here */ -} - -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); + printf("copy completed: %d records copied\n", record); }