Changeset 80e9e5e in mainline for uspace/app
- Timestamp:
- 2011-07-27T01:54:34Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0837ab4
- Parents:
- c936c7f (diff), 75aa59a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 4 edited
-
bdsh/cmds/modules/cp/cp.c (modified) (2 diffs)
-
bdsh/compl.c (modified) (1 diff)
-
taskdump/elf_core.c (modified) (10 diffs)
-
taskdump/symtab.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cp/cp.c
rc936c7f r80e9e5e 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; -
uspace/app/bdsh/compl.c
rc936c7f r80e9e5e 280 280 281 281 cs->dir = opendir(*cs->path); 282 283 /* Skip directories that we fail to open. */ 284 if (cs->dir == NULL) 285 cs->path++; 282 286 } 283 287 -
uspace/app/taskdump/elf_core.c
rc936c7f r80e9e5e 67 67 68 68 static off64_t align_foff_up(off64_t, uintptr_t, size_t); 69 static int write_all(int, const void *, size_t);70 69 static int align_pos(int, size_t); 71 70 static int write_mem_area(int, as_area_info_t *, async_sess_t *); … … 100 99 101 100 int fd; 102 int rc;101 ssize_t rc; 103 102 unsigned int i; 104 103 … … 204 203 205 204 rc = write_all(fd, &elf_hdr, sizeof(elf_hdr)); 206 if (rc != EOK) {205 if (rc != sizeof(elf_hdr)) { 207 206 printf("Failed writing ELF header.\n"); 208 207 free(p_hdr); … … 212 211 for (i = 0; i < n_ph; ++i) { 213 212 rc = write_all(fd, &p_hdr[i], sizeof(p_hdr[i])); 214 if (rc != EOK) {213 if (rc != sizeof(p_hdr[i])) { 215 214 printf("Failed writing program header.\n"); 216 215 free(p_hdr); … … 233 232 234 233 rc = write_all(fd, ¬e, sizeof(elf_note_t)); 235 if (rc != EOK) {234 if (rc != sizeof(elf_note_t)) { 236 235 printf("Failed writing note header.\n"); 237 236 free(p_hdr); … … 240 239 241 240 rc = write_all(fd, "CORE", note.namesz); 242 if (rc != EOK) {241 if (rc != (ssize_t) note.namesz) { 243 242 printf("Failed writing note header.\n"); 244 243 free(p_hdr); … … 254 253 255 254 rc = write_all(fd, &pr_status, sizeof(elf_prstatus_t)); 256 if (rc != EOK) {255 if (rc != sizeof(elf_prstatus_t)) { 257 256 printf("Failed writing register data.\n"); 258 257 free(p_hdr); … … 304 303 size_t total; 305 304 uintptr_t addr; 306 int rc;305 ssize_t rc; 307 306 308 307 addr = area->start_addr; … … 318 317 319 318 rc = write_all(fd, buffer, to_copy); 320 if (rc != EOK) {319 if (rc != (ssize_t) to_copy) { 321 320 printf("Failed writing memory contents.\n"); 322 321 return EIO; … … 326 325 total += to_copy; 327 326 } 328 329 return EOK;330 }331 332 /** Write until the buffer is written in its entirety.333 *334 * This function fails if it cannot write exactly @a len bytes to the file.335 *336 * @param fd The file to write to.337 * @param buf Data, @a len bytes long.338 * @param len Number of bytes to write.339 *340 * @return EOK on error, return value from write() if writing341 * failed.342 */343 static int write_all(int fd, const void *data, size_t len)344 {345 int cnt = 0;346 347 do {348 data += cnt;349 len -= cnt;350 cnt = write(fd, data, len);351 } while (cnt > 0 && (len - cnt) > 0);352 353 if (cnt < 0)354 return cnt;355 356 if (len - cnt > 0)357 return EIO;358 327 359 328 return EOK; -
uspace/app/taskdump/symtab.c
rc936c7f r80e9e5e 50 50 elf_section_header_t *shdr); 51 51 static int chunk_load(int fd, off64_t start, size_t size, void **ptr); 52 static int read_all(int fd, void *buf, size_t len);53 52 54 53 /** Load symbol table from an ELF file. … … 90 89 91 90 rc = read_all(fd, &elf_hdr, sizeof(elf_header_t)); 92 if (rc != EOK) {91 if (rc != sizeof(elf_header_t)) { 93 92 printf("failed reading elf header\n"); 94 93 free(stab); … … 312 311 313 312 rc = read_all(fd, sec_hdr, sizeof(elf_section_header_t)); 314 if (rc != EOK)313 if (rc != sizeof(elf_section_header_t)) 315 314 return EIO; 316 315 … … 331 330 static int chunk_load(int fd, off64_t start, size_t size, void **ptr) 332 331 { 333 int rc; 334 335 rc = lseek(fd, start, SEEK_SET); 336 if (rc == (off64_t) -1) { 332 ssize_t rc; 333 off64_t offs; 334 335 offs = lseek(fd, start, SEEK_SET); 336 if (offs == (off64_t) -1) { 337 337 printf("failed seeking chunk\n"); 338 338 *ptr = NULL; … … 347 347 348 348 rc = read_all(fd, *ptr, size); 349 if (rc != EOK) {349 if (rc != (ssize_t) size) { 350 350 printf("failed reading chunk\n"); 351 351 free(*ptr); … … 357 357 } 358 358 359 /** Read until the buffer is read in its entirety.360 *361 * This function fails if it cannot read exactly @a len bytes from the file.362 *363 * @param fd The file to read from.364 * @param buf Buffer for storing data, @a len bytes long.365 * @param len Number of bytes to read.366 *367 * @return EOK on error, EIO if file is short or return value368 * from read() if reading failed.369 */370 static int read_all(int fd, void *buf, size_t len)371 {372 int cnt = 0;373 374 do {375 buf += cnt;376 len -= cnt;377 cnt = read(fd, buf, len);378 } while (cnt > 0 && (len - cnt) > 0);379 380 if (cnt < 0)381 return cnt;382 383 if (len - cnt > 0)384 return EIO;385 386 return EOK;387 }388 389 359 /** @} 390 360 */
Note:
See TracChangeset
for help on using the changeset viewer.
