Changeset 8e3498b in mainline for uspace/app/taskdump


Ignore:
Timestamp:
2017-12-04T18:44:24Z (8 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bde5c04
Parents:
40feeac
Message:

vfs_read/write() should return error code separately from number of bytes transferred.

Location:
uspace/app/taskdump
Files:
2 edited

Legend:

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

    r40feeac r8e3498b  
    9797
    9898        int fd;
    99         ssize_t rc;
     99        int rc;
     100        size_t nwr;
    100101        unsigned int i;
    101102
     
    206207        }
    207208
    208         rc = vfs_write(fd, &pos, &elf_hdr, sizeof(elf_hdr));
    209         if (rc != sizeof(elf_hdr)) {
     209        rc = vfs_write(fd, &pos, &elf_hdr, sizeof(elf_hdr), &nwr);
     210        if (rc != EOK) {
    210211                printf("Failed writing ELF header.\n");
    211212                free(p_hdr);
     
    214215
    215216        for (i = 0; i < n_ph; ++i) {
    216                 rc = vfs_write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i]));
    217                 if (rc != sizeof(p_hdr[i])) {
     217                rc = vfs_write(fd, &pos, &p_hdr[i], sizeof(p_hdr[i]), &nwr);
     218                if (rc != EOK) {
    218219                        printf("Failed writing program header.\n");
    219220                        free(p_hdr);
     
    231232        note.type = NT_PRSTATUS;
    232233
    233         rc = vfs_write(fd, &pos, &note, sizeof(elf_note_t));
    234         if (rc != sizeof(elf_note_t)) {
     234        rc = vfs_write(fd, &pos, &note, sizeof(elf_note_t), &nwr);
     235        if (rc != EOK) {
    235236                printf("Failed writing note header.\n");
    236237                free(p_hdr);
     
    238239        }
    239240
    240         rc = vfs_write(fd, &pos, "CORE", note.namesz);
    241         if (rc != (ssize_t) note.namesz) {
     241        rc = vfs_write(fd, &pos, "CORE", note.namesz, &nwr);
     242        if (rc != EOK) {
    242243                printf("Failed writing note header.\n");
    243244                free(p_hdr);
     
    247248        pos = ALIGN_UP(pos, word_size);
    248249
    249         rc = vfs_write(fd, &pos, &pr_status, sizeof(elf_prstatus_t));
    250         if (rc != sizeof(elf_prstatus_t)) {
     250        rc = vfs_write(fd, &pos, &pr_status, sizeof(elf_prstatus_t), &nwr);
     251        if (rc != EOK) {
    251252                printf("Failed writing register data.\n");
    252253                free(p_hdr);
     
    296297        size_t total;
    297298        uintptr_t addr;
    298         ssize_t rc;
     299        int rc;
     300        size_t nwr;
    299301
    300302        addr = area->start_addr;
     
    309311                }
    310312
    311                 rc = vfs_write(fd, pos, buffer, to_copy);
    312                 if (rc != (ssize_t) to_copy) {
     313                rc = vfs_write(fd, pos, buffer, to_copy, &nwr);
     314                if (rc != EOK) {
    313315                        printf("Failed writing memory contents.\n");
    314316                        return EIO;
  • uspace/app/taskdump/symtab.c

    r40feeac r8e3498b  
    7171        int fd;
    7272        int rc;
     73        size_t nread;
    7374        int i;
    7475
     
    8889        }
    8990
    90         rc = vfs_read(fd, &pos, &elf_hdr, sizeof(elf_header_t));
    91         if (rc != sizeof(elf_header_t)) {
     91        rc = vfs_read(fd, &pos, &elf_hdr, sizeof(elf_header_t), &nread);
     92        if (rc != EOK || nread != sizeof(elf_header_t)) {
    9293                printf("failed reading elf header\n");
    9394                free(stab);
     
    304305{
    305306        int rc;
     307        size_t nread;
    306308        aoff64_t pos = elf_hdr->e_shoff + idx * sizeof(elf_section_header_t);
    307309
    308         rc = vfs_read(fd, &pos, sec_hdr, sizeof(elf_section_header_t));
    309         if (rc != sizeof(elf_section_header_t))
     310        rc = vfs_read(fd, &pos, sec_hdr, sizeof(elf_section_header_t), &nread);
     311        if (rc != EOK || nread != sizeof(elf_section_header_t))
    310312                return EIO;
    311313
     
    326328static int chunk_load(int fd, off64_t start, size_t size, void **ptr)
    327329{
    328         ssize_t rc;
     330        int rc;
     331        size_t nread;
    329332        aoff64_t pos = start;
    330333
     
    335338        }
    336339
    337         rc = vfs_read(fd, &pos, *ptr, size);
    338         if (rc != (ssize_t) size) {
     340        rc = vfs_read(fd, &pos, *ptr, size, &nread);
     341        if (rc != EOK || nread != size) {
    339342                printf("failed reading chunk\n");
    340343                free(*ptr);
Note: See TracChangeset for help on using the changeset viewer.