Changes in uspace/app/bdsh/cmds/modules/cp/cp.c [6348376:36ab7c7] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
r6348376 r36ab7c7 71 71 size_t blen, int vb) 72 72 { 73 int fd1, fd2, bytes ;74 off64_t total ;73 int fd1, fd2, bytes = 0; 74 off64_t total = 0; 75 75 int64_t copied = 0; 76 76 char *buff = NULL; … … 104 104 } 105 105 106 while ((bytes = read_all(fd1, buff, blen)) > 0) { 107 if ((bytes = write_all(fd2, buff, bytes)) < 0) 106 for (;;) { 107 ssize_t res; 108 size_t written = 0; 109 110 bytes = read(fd1, buff, blen); 111 if (bytes <= 0) 108 112 break; 109 113 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 have 119 * 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 shell 130 */ 131 if (res != 0) { 132 printf("\n%zd more bytes than actually exist were copied\n", res); 133 goto err; 134 } 110 135 } 111 136 112 137 if (bytes < 0) { 138 err: 113 139 printf("\nError copying %s, (%d)\n", src, bytes); 114 140 copied = bytes;
Note:
See TracChangeset
for help on using the changeset viewer.