[BusyBox] broken copyfd.c

Larry Doolittle ldoolitt at recycle.lbl.gov
Thu May 17 15:21:51 UTC 2001


Is my system strange, or has nobody tested
cp or cat recently?

     - Larry

--- /home/ldoolitt/cvs/busybox/libbb/copyfd.c	Tue May 15 10:48:09 2001
+++ copyfd.c	Thu May 17 14:10:26 2001
@@ -27,23 +27,25 @@
 
 extern size_t copyfd(int fd1, int fd2)
 {
-	char buf[32768], *writebuf;
+	char buf[8192], *writebuf;
 	int status = TRUE;
 	size_t totalread = 0, bytesread, byteswritten;
 
 	while(status) {
 		bytesread = read(fd1, &buf, sizeof(buf));
 		if(bytesread == -1) {
-			error_msg("read: %s", strerror(errno));
+			perror_msg("read");
 			status = FALSE;
 			break;
 		}
+		if (bytesread == 0) break;
+		totalread += bytesread;
 		byteswritten = 0;
 		writebuf = buf;
 		while(bytesread) {
-			byteswritten = write( fd2, &writebuf, bytesread );
+			byteswritten = write( fd2, writebuf, bytesread );
 			if(byteswritten == -1) {
-				error_msg("write: %s", strerror(errno));
+				perror_msg("write");
 				status = FALSE;
 				break;
 			}





More information about the busybox mailing list