]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/posix/pwritev2.c
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / posix / pwritev2.c
index 7ec8cbc4074a3c0aeb016a71ce51aa52ba3f3e88..595fb0248d197da3c3537888f628c268269c6ab4 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic version of pwritev2.
-   Copyright (C) 2017 Free Software Foundation, Inc.
+   Copyright (C) 2017-2021 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -14,8 +14,9 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
+   <https://www.gnu.org/licenses/>.  */
 
+#include <errno.h>
 #include <unistd.h>
 #include <sys/uio.h>
 
@@ -23,7 +24,7 @@
 
 /* Since we define no flags for pwritev2 just route to pwritev.  */
 ssize_t
-pwritev2 (int fd, const struct iovec *vector, int count, OFF_T offset,
+pwritev2 (int fd, const struct iovec *vector, int count, off_t offset,
          int flags)
 {
   if (flags != 0)
@@ -32,7 +33,10 @@ pwritev2 (int fd, const struct iovec *vector, int count, OFF_T offset,
       return -1;
     }
 
-  return pwritev (fd, vector, count, offset);
+  if (offset == -1)
+    return __writev (fd, vector, count);
+  else
+    return pwritev (fd, vector, count, offset);
 }
 
 #endif