aboutsummaryrefslogtreecommitdiff
path: root/wrapper.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2026-03-13 07:45:17 +0100
committerJunio C Hamano <gitster@pobox.com>2026-03-13 08:54:14 -0700
commit1970fcef93adcc5a35f6468d00a5a634d5af2b3c (patch)
tree72a7d14cd6856beff59ccdf49a71dcda0066f06a /wrapper.h
parent3b9b2c2a29a1d529ca9884fa0a6529f6e2496abe (diff)
downloadgit-1970fcef93adcc5a35f6468d00a5a634d5af2b3c.tar.xz
wrapper: introduce writev(3p) wrappers
In the preceding commit we have added a compatibility wrapper for the writev(3p) syscall. Introduce some generic wrappers for this function that we nowadays take for granted in the Git codebase. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wrapper.h')
-rw-r--r--wrapper.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/wrapper.h b/wrapper.h
index 15ac3bab6e..27519b32d1 100644
--- a/wrapper.h
+++ b/wrapper.h
@@ -47,6 +47,15 @@ ssize_t read_in_full(int fd, void *buf, size_t count);
ssize_t write_in_full(int fd, const void *buf, size_t count);
ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset);
+/*
+ * Try to write all iovecs. Returns -1 in case an error occurred with a proper
+ * errno set, the number of bytes written otherwise.
+ *
+ * Note that the iovec will be modified as a result of this call to adjust for
+ * partial writes!
+ */
+ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt);
+
static inline ssize_t write_str_in_full(int fd, const char *str)
{
return write_in_full(fd, str, strlen(str));