Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset c566782 in mainline


Ignore:
Timestamp:
2011-07-25T20:24:56Z (10 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
aa865ee
Parents:
6348376
Message:

Use read_all() in elf_load.c.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/elf/elf_load.c

    r6348376 rc566782  
    7474static int load_segment(elf_ld_t *elf, elf_segment_header_t *entry);
    7575
    76 /** Read until the buffer is read in its entirety. */
    77 static int my_read(int fd, void *buf, size_t len)
    78 {
    79         int cnt = 0;
    80         do {
    81                 buf += cnt;
    82                 len -= cnt;
    83                 cnt = read(fd, buf, len);
    84         } while ((cnt > 0) && ((len - cnt) > 0));
    85 
    86         return cnt;
    87 }
    88 
    8976/** Load ELF binary from a file.
    9077 *
     
    160147        int i, rc;
    161148
    162         rc = my_read(elf->fd, header, sizeof(elf_header_t));
     149        rc = read_all(elf->fd, header, sizeof(elf_header_t));
    163150        if (rc < 0) {
    164151                DPRINTF("Read error.\n");
     
    222209                        + i * sizeof(elf_segment_header_t), SEEK_SET);
    223210
    224                 rc = my_read(elf->fd, &segment_hdr,
     211                rc = read_all(elf->fd, &segment_hdr,
    225212                    sizeof(elf_segment_header_t));
    226213                if (rc < 0) {
     
    244231                    + i * sizeof(elf_section_header_t), SEEK_SET);
    245232
    246                 rc = my_read(elf->fd, &section_hdr,
     233                rc = read_all(elf->fd, &section_hdr,
    247234                    sizeof(elf_section_header_t));
    248235                if (rc < 0) {
     
    412399                if (now > left) now = left;
    413400
    414                 rc = my_read(elf->fd, dp, now);
     401                rc = read_all(elf->fd, dp, now);
    415402
    416403                if (rc < 0) {
Note: See TracChangeset for help on using the changeset viewer.