* grub-core/osdep/unix/hostdisk.c (grub_util_fd_read): Return correct

value in case of incomplete read.
	(grub_util_fd_write): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-10-16 00:20:07 +02:00
parent 593816780e
commit 669fc44923
2 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,9 @@
2013-10-16 Vladimir Serbinenko <phcoder@gmail.com>
* 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 <phcoder@gmail.com>
* util/editenv.c (grub_util_create_envblk_file): Use grub_util_rename.

View file

@ -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;