summaryrefslogtreecommitdiff
path: root/sysdeps/posix
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/preadv.c4
-rw-r--r--sysdeps/posix/pwritev.c34
-rw-r--r--sysdeps/posix/readv.c2
3 files changed, 14 insertions, 26 deletions
diff --git a/sysdeps/posix/preadv.c b/sysdeps/posix/preadv.c
index e697604c19..791077399e 100644
--- a/sysdeps/posix/preadv.c
+++ b/sysdeps/posix/preadv.c
@@ -48,7 +48,7 @@ ifree (char **ptrp)
without change the file pointer, and put the result in the buffers
described by VECTOR, which is a vector of COUNT 'struct iovec's.
The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
+ 'pread' (see <unistd.h>) except that data are put in VECTOR instead
of a contiguous buffer. */
ssize_t
PREADV (int fd, const struct iovec *vector, int count, OFF_T offset)
@@ -83,7 +83,7 @@ PREADV (int fd, const struct iovec *vector, int count, OFF_T offset)
/* Read the data. */
ssize_t bytes_read = PREAD (fd, buffer, bytes, offset);
- if (bytes_read <= 0)
+ if (bytes_read < 0)
return -1;
/* Copy the data from BUFFER into the memory specified by VECTOR. */
diff --git a/sysdeps/posix/pwritev.c b/sysdeps/posix/pwritev.c
index 0b6627dc9d..f2f0574aac 100644
--- a/sysdeps/posix/pwritev.c
+++ b/sysdeps/posix/pwritev.c
@@ -44,12 +44,12 @@ ifree (char **ptrp)
}
-/* Read data from file descriptor FD at the given position OFFSET
- without change the file pointer, and put the result in the buffers
- described by VECTOR, which is a vector of COUNT 'struct iovec's.
- The buffers are filled in the order specified. Operates just like
- 'read' (see <unistd.h>) except that data are put in VECTOR instead
- of a contiguous buffer. */
+/* Write data pointed by the buffers described by IOVEC, which is a
+ vector of COUNT 'struct iovec's, to file descriptor FD at the given
+ position OFFSET without change the file pointer. The data is
+ written in the order specified. Operates just like 'write' (see
+ <unistd.h>) except that the data are taken from IOVEC instead of a
+ contiguous buffer. */
ssize_t
PWRITEV (int fd, const struct iovec *vector, int count, OFF_T offset)
{
@@ -81,26 +81,14 @@ PWRITEV (int fd, const struct iovec *vector, int count, OFF_T offset)
return -1;
}
- /* Read the data. */
- ssize_t bytes_read = PWRITE (fd, buffer, bytes, offset);
- if (bytes_read <= 0)
- return -1;
-
/* Copy the data from BUFFER into the memory specified by VECTOR. */
- bytes = bytes_read;
+ char *ptr = buffer;
for (int i = 0; i < count; ++i)
- {
- size_t copy = MIN (vector[i].iov_len, bytes);
-
- (void) memcpy ((void *) vector[i].iov_base, (void *) buffer, copy);
-
- buffer += copy;
- bytes -= copy;
- if (bytes == 0)
- break;
- }
+ ptr = __mempcpy ((void *) ptr, (void *) vector[i].iov_base,
+ vector[i].iov_len);
- return bytes_read;
+ /* Write the data. */
+ return PWRITE (fd, buffer, bytes, offset);
}
#if __WORDSIZE == 64 && defined pwritev64
# undef pwritev64
diff --git a/sysdeps/posix/readv.c b/sysdeps/posix/readv.c
index 50bcc91315..6f16b9d946 100644
--- a/sysdeps/posix/readv.c
+++ b/sysdeps/posix/readv.c
@@ -70,7 +70,7 @@ __libc_readv (int fd, const struct iovec *vector, int count)
/* Read the data. */
ssize_t bytes_read = __read (fd, buffer, bytes);
- if (bytes_read <= 0)
+ if (bytes_read < 0)
return -1;
/* Copy the data from BUFFER into the memory specified by VECTOR. */