Changes in uspace/app/taskdump/symtab.c [8fd04ba9:ed903174] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/taskdump/symtab.c
r8fd04ba9 red903174 36 36 */ 37 37 38 #include <elf/elf.h>39 38 #include <stdio.h> 40 39 #include <stdlib.h> … … 44 43 #include <fcntl.h> 45 44 45 #include <elf.h> 46 46 #include "include/symtab.h" 47 47 … … 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); 52 53 53 54 /** Load symbol table from an ELF file. … … 89 90 90 91 rc = read_all(fd, &elf_hdr, sizeof(elf_header_t)); 91 if (rc != sizeof(elf_header_t)) {92 if (rc != EOK) { 92 93 printf("failed reading elf header\n"); 93 94 free(stab); … … 311 312 312 313 rc = read_all(fd, sec_hdr, sizeof(elf_section_header_t)); 313 if (rc != sizeof(elf_section_header_t))314 if (rc != EOK) 314 315 return EIO; 315 316 … … 330 331 static int chunk_load(int fd, off64_t start, size_t size, void **ptr) 331 332 { 332 ssize_t rc; 333 off64_t offs; 334 335 offs = lseek(fd, start, SEEK_SET); 336 if (offs == (off64_t) -1) { 333 int rc; 334 335 rc = lseek(fd, start, SEEK_SET); 336 if (rc == (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 != (ssize_t) size) {349 if (rc != EOK) { 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 value 368 * 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 359 389 /** @} 360 390 */
Note:
See TracChangeset
for help on using the changeset viewer.