diff --git a/ChangeLog b/ChangeLog index 791fd9416..757b1e6c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-10-16 Vladimir Serbinenko + + * grub-core/osdep/unix/hostdisk.c (grub_util_fd_read): Return correct + value in case of incomplete read. + (grub_util_fd_write): Likewise. + 2013-10-15 Vladimir Serbinenko * util/editenv.c (grub_util_create_envblk_file): Use grub_util_rename. diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index 9734a1db5..fe87855e2 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -115,13 +115,16 @@ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) ssize_t grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len) { - ssize_t size = len; + ssize_t size = 0; while (len) { ssize_t ret = read (fd, buf, len); - if (ret <= 0) + if (ret == 0) + break; + + if (ret < 0) { if (errno == EINTR) continue; @@ -131,6 +134,7 @@ grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len) len -= ret; buf += ret; + size += ret; } return size; @@ -141,13 +145,16 @@ grub_util_fd_read (grub_util_fd_t fd, char *buf, size_t len) ssize_t grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len) { - ssize_t size = len; + ssize_t size = 0; while (len) { ssize_t ret = write (fd, buf, len); - if (ret <= 0) + if (ret == 0) + break; + + if (ret < 0) { if (errno == EINTR) continue; @@ -157,6 +164,7 @@ grub_util_fd_write (grub_util_fd_t fd, const char *buf, size_t len) len -= ret; buf += ret; + size += ret; } return size;