#include #include #include #include #include #include #include #include #include #include int main() { struct iovec iov[2]; size_t psz; char *a, *b; int fd, rv; psz = getpagesize(); a = mmap(NULL, psz, PROT_NONE, MAP_ANON, -1, 0); if (a == MAP_FAILED) err(1, "mmap 1"); b = mmap(a + psz, psz, PROT_READ, MAP_ANON | MAP_FIXED, -1, 0); if (b == MAP_FAILED) err(1, "mmap 2"); fd = open("uiob.foo", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); if (fd == -1) err(1, "open"); iov[0].iov_base = a; iov[0].iov_len = psz; iov[1].iov_base = b; iov[1].iov_len = psz; rv = writev(fd, iov, 2); printf("writev returned %d\n", rv); if (rv == -1) printf("error %s\n", strerror(errno)); close(fd); return (0); }