Changes in uspace/app/bdsh/cmds/modules/cp/cp.c [36ab7c7:6348376] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
r36ab7c7 r6348376 71 71 size_t blen, int vb) 72 72 { 73 int fd1, fd2, bytes = 0;74 off64_t total = 0;73 int fd1, fd2, bytes; 74 off64_t total; 75 75 int64_t copied = 0; 76 76 char *buff = NULL; … … 104 104 } 105 105 106 for (;;) { 107 ssize_t res; 108 size_t written = 0; 109 110 bytes = read(fd1, buff, blen); 111 if (bytes <= 0) 106 while ((bytes = read_all(fd1, buff, blen)) > 0) { 107 if ((bytes = write_all(fd2, buff, bytes)) < 0) 112 108 break; 113 109 copied += bytes; 114 res = bytes;115 do {116 /*117 * Theoretically, it may not be enough to call write()118 * only once. Also the previous read() may have119 * returned less data than requested.120 */121 bytes = write(fd2, buff + written, res);122 if (bytes < 0)123 goto err;124 written += bytes;125 res -= bytes;126 } while (res > 0);127 128 /* TODO: re-insert assert() once this is stand alone,129 * removed as abort() exits the entire shell130 */131 if (res != 0) {132 printf("\n%zd more bytes than actually exist were copied\n", res);133 goto err;134 }135 110 } 136 111 137 112 if (bytes < 0) { 138 err:139 113 printf("\nError copying %s, (%d)\n", src, bytes); 140 114 copied = bytes;
Note:
See TracChangeset
for help on using the changeset viewer.