Revert "wrapper: introduce writev(3p) wrappers"
This reverts commit 1970fcef93adcc5a35f6468d00a5a634d5af2b3c; let's not use writev() for now.maint
parent
74fbd8a571
commit
dc1b8b2cc8
41
wrapper.c
41
wrapper.c
|
|
@ -323,47 +323,6 @@ ssize_t write_in_full(int fd, const void *buf, size_t count)
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t writev_in_full(int fd, struct iovec *iov, int iovcnt)
|
|
||||||
{
|
|
||||||
ssize_t total_written = 0;
|
|
||||||
|
|
||||||
while (iovcnt) {
|
|
||||||
ssize_t bytes_written = writev(fd, iov, iovcnt);
|
|
||||||
if (bytes_written < 0) {
|
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
|
||||||
continue;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!bytes_written) {
|
|
||||||
errno = ENOSPC;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
total_written += bytes_written;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We first need to discard any iovec entities that have been
|
|
||||||
* fully written.
|
|
||||||
*/
|
|
||||||
while (iovcnt && (size_t)bytes_written >= iov->iov_len) {
|
|
||||||
bytes_written -= iov->iov_len;
|
|
||||||
iov++;
|
|
||||||
iovcnt--;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Finally, we need to adjust the last iovec in case we have
|
|
||||||
* performed a partial write.
|
|
||||||
*/
|
|
||||||
if (iovcnt && bytes_written) {
|
|
||||||
iov->iov_base = (char *) iov->iov_base + bytes_written;
|
|
||||||
iov->iov_len -= bytes_written;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return total_written;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset)
|
ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset)
|
||||||
{
|
{
|
||||||
char *p = buf;
|
char *p = buf;
|
||||||
|
|
|
||||||
|
|
@ -47,15 +47,6 @@ 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 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);
|
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)
|
static inline ssize_t write_str_in_full(int fd, const char *str)
|
||||||
{
|
{
|
||||||
return write_in_full(fd, str, strlen(str));
|
return write_in_full(fd, str, strlen(str));
|
||||||
|
|
|
||||||
|
|
@ -96,14 +96,6 @@ void write_or_die(int fd, const void *buf, size_t count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void writev_or_die(int fd, struct iovec *iov, int iovlen)
|
|
||||||
{
|
|
||||||
if (writev_in_full(fd, iov, iovlen) < 0) {
|
|
||||||
check_pipe(errno);
|
|
||||||
die_errno("writev error");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fwrite_or_die(FILE *f, const void *buf, size_t count)
|
void fwrite_or_die(FILE *f, const void *buf, size_t count)
|
||||||
{
|
{
|
||||||
if (fwrite(buf, 1, count, f) != count)
|
if (fwrite(buf, 1, count, f) != count)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ void fprintf_or_die(FILE *, const char *fmt, ...);
|
||||||
void fwrite_or_die(FILE *f, const void *buf, size_t count);
|
void fwrite_or_die(FILE *f, const void *buf, size_t count);
|
||||||
void fflush_or_die(FILE *f);
|
void fflush_or_die(FILE *f);
|
||||||
void write_or_die(int fd, const void *buf, size_t count);
|
void write_or_die(int fd, const void *buf, size_t count);
|
||||||
void writev_or_die(int fd, struct iovec *iov, int iovlen);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These values are used to help identify parts of a repository to fsync.
|
* These values are used to help identify parts of a repository to fsync.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue