1 /*-------------------------------------------------------------------------
4 * Implementation of pwritev(2) for platforms that lack one.
6 * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
11 * Note that this implementation changes the current file position, unlike
12 * the POSIX-like function, so we use the name pg_pwritev().
14 *-------------------------------------------------------------------------
26 #include "port/pg_iovec.h"
29 pg_pwritev(int fd
, const struct iovec
*iov
, int iovcnt
, off_t offset
)
33 return pg_pwrite(fd
, iov
[0].iov_base
, iov
[0].iov_len
, offset
);
34 if (lseek(fd
, offset
, SEEK_SET
) < 0)
36 return writev(fd
, iov
, iovcnt
);
41 for (int i
= 0; i
< iovcnt
; ++i
)
43 part
= pg_pwrite(fd
, iov
[i
].iov_base
, iov
[i
].iov_len
, offset
);
53 if (part
< iov
[i
].iov_len
)