summaryrefslogtreecommitdiffstats
path: root/libc/unistd/pwrite.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd/pwrite.c')
-rw-r--r--libc/unistd/pwrite.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/libc/unistd/pwrite.c b/libc/unistd/pwrite.c
index 7f5e071..5adf40a 100644
--- a/libc/unistd/pwrite.c
+++ b/libc/unistd/pwrite.c
@@ -27,23 +27,11 @@
*/
#include <sys/types.h>
#include <unistd.h>
-#include <errno.h>
-/*
- * Non-atomic emulation of the pwrite system call.
- */
-ssize_t pwrite(int fd, void *buf, size_t count, off_t offset)
+extern int __pwrite64(int fd, void *buf, size_t nbytes, off_t lo, off_t hi);
+
+ssize_t pwrite(int fd, void *buf, size_t nbytes, off_t offset)
{
- int save_errno;
- ssize_t nwrite;
- off_t save_offset = lseek(fd, offset, SEEK_SET);
- if (save_offset < 0) {
- return -1;
- }
- nwrite = write(fd, buf, count);
- save_errno = errno;
- /* Even if the write failed, try to restore the seek pointer */
- lseek(fd, save_offset, SEEK_SET);
- errno = save_errno;
- return nwrite;
+ return __pwrite64(fd, buf, nbytes, offset, 0);
}
+