diff options
author | Ulrich Drepper <drepper@redhat.com> | 2005-08-29 06:25:06 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2005-08-29 06:25:06 +0000 |
commit | 6abe27be7178a891326f29337a7aa31aa3e5482d (patch) | |
tree | 5aab3d095cd0f5bc62d5e3f004023032a005c913 /libelf/elf32_updatefile.c | |
parent | c2c3b1ecbe235c4e04ddcbafe6f0f27dccd86d9b (diff) | |
download | elfutils-6abe27be7178a891326f29337a7aa31aa3e5482d.tar.gz |
Fix more EINTR handling problems. Add jump prediction.
Diffstat (limited to 'libelf/elf32_updatefile.c')
-rw-r--r-- | libelf/elf32_updatefile.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c index 14893def..260fb346 100644 --- a/libelf/elf32_updatefile.c +++ b/libelf/elf32_updatefile.c @@ -20,6 +20,7 @@ #endif #include <assert.h> +#include <errno.h> #include <libelf.h> #include <stdbool.h> #include <stdlib.h> @@ -27,6 +28,7 @@ #include <unistd.h> #include <sys/param.h> +#include <system.h> #include "libelfP.h" @@ -326,7 +328,7 @@ fill (int fd, off_t pos, size_t len, char *fillbuf, size_t *filledp) /* This many bytes we want to write in this round. */ size_t n = MIN (filled, len); - if (unlikely ((size_t) pwrite (fd, fillbuf, n, pos) != n)) + if (unlikely ((size_t) pwrite_retry (fd, fillbuf, n, pos) != n)) { __libelf_seterrno (ELF_E_WRITE_ERROR); return 1; @@ -381,8 +383,8 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) } /* Write out the ELF header. */ - if (unlikely (pwrite (elf->fildes, out_ehdr, - sizeof (ElfW2(LIBELFBITS,Ehdr)), 0) + if (unlikely (pwrite_retry (elf->fildes, out_ehdr, + sizeof (ElfW2(LIBELFBITS,Ehdr)), 0) != sizeof (ElfW2(LIBELFBITS,Ehdr)))) { __libelf_seterrno (ELF_E_WRITE_ERROR); @@ -441,10 +443,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) } /* Write out the ELF header. */ - if (unlikely ((size_t) pwrite (elf->fildes, out_phdr, - sizeof (ElfW2(LIBELFBITS,Phdr)) - * ehdr->e_phnum, ehdr->e_phoff) - != sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum)) + size_t phdr_size = sizeof (ElfW2(LIBELFBITS,Phdr)) * ehdr->e_phnum; + if (unlikely ((size_t) pwrite_retry (elf->fildes, out_phdr, + phdr_size, ehdr->e_phoff) + != phdr_size)) { __libelf_seterrno (ELF_E_WRITE_ERROR); return 1; @@ -544,10 +546,10 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) (*fctp) (buf, dl->data.d.d_buf, dl->data.d.d_size, 1); } - if (unlikely ((size_t) pwrite (elf->fildes, buf, - dl->data.d.d_size, - last_offset) - != dl->data.d.d_size)) + ssize_t n = pwrite_retry (elf->fildes, buf, + dl->data.d.d_size, + last_offset); + if (unlikely ((size_t) n != dl->data.d.d_size)) { if (buf != dl->data.d.d_buf && buf != tmpbuf) free (buf); @@ -593,9 +595,9 @@ __elfw2(LIBELFBITS,updatefile) (Elf *elf, int change_bo, size_t shnum) /* Write out the section header table. */ if (shdr_flags & ELF_F_DIRTY - && unlikely ((size_t) pwrite (elf->fildes, shdr_data, - sizeof (ElfW2(LIBELFBITS,Shdr)) - * shnum, shdr_offset) + && unlikely ((size_t) pwrite_retry (elf->fildes, shdr_data, + sizeof (ElfW2(LIBELFBITS,Shdr)) + * shnum, shdr_offset) != sizeof (ElfW2(LIBELFBITS,Shdr)) * shnum)) { __libelf_seterrno (ELF_E_WRITE_ERROR); |