ssize_t write_data_iov(int fd, const struct iovec *orig_iov, int iovcnt) { ssize_t to_send; ssize_t thistime; size_t sent; struct iovec iov_copy[iovcnt]; struct iovec *iov; to_send = iov_buflen(orig_iov, iovcnt); if (to_send == -1) { errno = EINVAL; return -1; } thistime = sys_writev(fd, orig_iov, iovcnt); if ((thistime <= 0) || (thistime == to_send)) { return thistime; } sent = thistime; /* * We could not send everything in one call. Make a copy of iov that * we can mess with. We keep a copy of the array start in iov_copy for * the TALLOC_FREE, because we're going to modify iov later on, * discarding elements. */ memcpy(iov_copy, orig_iov, sizeof(struct iovec) * iovcnt); iov = iov_copy; while (sent < to_send) { /* * We have to discard "thistime" bytes from the beginning * iov array, "thistime" contains the number of bytes sent * via writev last. */ while (thistime > 0) { if (thistime < iov[0].iov_len) { char *new_base = (char *)iov[0].iov_base + thistime; iov[0].iov_base = (void *)new_base; iov[0].iov_len -= thistime; break; } thistime -= iov[0].iov_len; iov += 1; iovcnt -= 1; } thistime = sys_writev(fd, iov, iovcnt); if (thistime <= 0) { break; } sent += thistime; } return sent; }
__attribute__((noreturn)) static void fail(const char *filename, const char *message, const char *item1, int value1, const char *item2, int value2) { char valbuf1[32]; char valbuf2[32]; struct kernel_iovec iov[] = { STRING_IOV("bootstrap_helper: ", 1), { (void *) filename, my_strlen(filename) }, STRING_IOV(": ", 1), { (void *) message, my_strlen(message) }, { (void *) item1, item1 == NULL ? 0 : my_strlen(item1) }, STRING_IOV("=", item1 != NULL), { NULL, 0 }, /* iov[6] */ STRING_IOV(", ", item1 != NULL && item2 != NULL), { (void *) item2, item2 == NULL ? 0 : my_strlen(item2) }, STRING_IOV("=", item2 != NULL), { NULL, 0 }, /* iov[10] */ { "\n", 1 }, }; const int niov = sizeof(iov) / sizeof(iov[0]); if (item1 != NULL) iov_int_string(value1, &iov[6], valbuf1, sizeof(valbuf1)); if (item2 != NULL) iov_int_string(value2, &iov[10], valbuf2, sizeof(valbuf2)); sys_writev(2, iov, niov); sys_exit_group(2); while (1) *(volatile int *) 0 = 0; /* Crash. */ }
asmlinkage int sunos_writev(unsigned long fd, const struct iovec __user *vector, long count) { int ret; ret = check_nonblock(sys_writev(fd,vector,count),fd); return ret; }
long syscall_SYS_writev(int fd, const struct iovec *iov, int iovcnt){ //return strace(sys_writev, "writev", fd, iov, iovcnt); return sys_writev(fd, iov, iovcnt); }
ssize_t writev(int fd, const struct iovec* iov, int iovcnt) { return sys_writev(fd, iov, iovcnt); }