Changeset 7ae249d in mainline for uspace/app/taskdump/symtab.c


Ignore:
Timestamp:
2011-07-29T14:47:52Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
00c2de63, 1814ee4d, ffff746
Parents:
9350bfdd (diff), f5d51de (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.
Message:

Merge mainline.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/symtab.c

    r9350bfdd r7ae249d  
    3636 */
    3737
     38#include <elf/elf.h>
    3839#include <stdio.h>
    3940#include <stdlib.h>
     
    4344#include <fcntl.h>
    4445
    45 #include <elf.h>
    4646#include "include/symtab.h"
    4747
     
    5050    elf_section_header_t *shdr);
    5151static 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);
    5352
    5453/** Load symbol table from an ELF file.
     
    9089
    9190        rc = read_all(fd, &elf_hdr, sizeof(elf_header_t));
    92         if (rc != EOK) {
     91        if (rc != sizeof(elf_header_t)) {
    9392                printf("failed reading elf header\n");
    9493                free(stab);
     
    312311
    313312        rc = read_all(fd, sec_hdr, sizeof(elf_section_header_t));
    314         if (rc != EOK)
     313        if (rc != sizeof(elf_section_header_t))
    315314                return EIO;
    316315
     
    331330static int chunk_load(int fd, off64_t start, size_t size, void **ptr)
    332331{
    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) {
    337337                printf("failed seeking chunk\n");
    338338                *ptr = NULL;
     
    347347
    348348        rc = read_all(fd, *ptr, size);
    349         if (rc != EOK) {
     349        if (rc != (ssize_t) size) {
    350350                printf("failed reading chunk\n");
    351351                free(*ptr);
     
    357357}
    358358
    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 
    389359/** @}
    390360 */
Note: See TracChangeset for help on using the changeset viewer.