130246Smckusick /*
230246Smckusick * Copyright (c) 1986 Regents of the University of California.
333478Sbostic * All rights reserved.
433478Sbostic *
533478Sbostic * Redistribution and use in source and binary forms are permitted
634834Sbostic * provided that the above copyright notice and this paragraph are
734834Sbostic * duplicated in all such forms and that any documentation,
834834Sbostic * advertising materials, and other materials related to such
934834Sbostic * distribution and use acknowledge that the software was developed
1034834Sbostic * by the University of California, Berkeley. The name of the
1134834Sbostic * University may not be used to endorse or promote products derived
1234834Sbostic * from this software without specific prior written permission.
1334834Sbostic * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1434834Sbostic * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1534834Sbostic * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1630246Smckusick */
1730246Smckusick
1830246Smckusick #ifndef lint
1930246Smckusick char copyright[] =
2030246Smckusick "@(#) Copyright (c) 1986 Regents of the University of California.\n\
2130246Smckusick All rights reserved.\n";
2233478Sbostic #endif /* not lint */
2330246Smckusick
2430246Smckusick #ifndef lint
25*34869Sbostic static char sccsid[] = "@(#)20b.c 5.5 (Berkeley) 06/29/88";
2633478Sbostic #endif /* not lint */
2730246Smckusick
2833482Sbostic #include <stdio.h>
2933482Sbostic
main(argc,argv)3033482Sbostic main(argc, argv)
3133482Sbostic int argc;
3233482Sbostic char **argv;
3330246Smckusick {
3433482Sbostic register int bsize, cc, want;
3530246Smckusick register char *base, *current;
3630246Smckusick char *alloca();
3730246Smckusick
3833482Sbostic if (argc > 1) {
3933482Sbostic bsize = atoi(argv[1]);
4033482Sbostic if (bsize <= 0) {
4133482Sbostic fputs("20b: bad block size.\n", stderr);
4233482Sbostic exit(-1);
4333482Sbostic }
4433482Sbostic }
45*34869Sbostic else
46*34869Sbostic bsize = 20 * 512;
4733482Sbostic base = alloca(bsize);
4833482Sbostic for (cc = bsize; cc > 0;) {
4930246Smckusick current = base;
5033482Sbostic for (want = bsize; want > 0 && cc > 0; want -= cc) {
5133478Sbostic if ((cc = read(0, current, want)) < 0)
5233478Sbostic return(-1);
5330246Smckusick current += cc;
5430246Smckusick }
5533482Sbostic want = bsize - want;
5633478Sbostic if (want && write(1, base, want) != want)
5733478Sbostic return(-1);
5830246Smckusick }
5930246Smckusick return(0);
6030246Smckusick }
61