1 #include <sys/uio.h> 2 #include <stdio.h> 3 #include <unistd.h> 4 #include <errno.h> 5 #include <string.h> 6 #include <fcntl.h> 7 8 int 9 main() 10 { 11 int fd = open("testfile", O_CREAT | O_RDWR, 0666); 12 13 if (fd < 0) { 14 printf("file open error %s\n", strerror(errno)); 15 return 1; 16 } 17 18 int dummy; 19 int ret; 20 iovec vec1 = { &dummy, sizeof(dummy) }; 21 ret = writev(fd, &vec1, 0x80000001); 22 23 if (ret < 0) { 24 printf("vec 1 write error %s\n", strerror(errno)); 25 } 26 27 iovec vec2 = { (void *)0x80100000, 0x1000 }; 28 ret = writev(fd, &vec2, 1); 29 30 if (ret < 0) { 31 printf("vec 2 write error %s\n", strerror(errno)); 32 } 33 34 iovec vec3 = { 0, 1 }; 35 ret = writev(fd, &vec3, 0xfff); 36 37 if (ret < 0) { 38 printf("vec 3 write error %s\n", strerror(errno)); 39 } 40 41 close(fd); 42 43 return 0; 44 } 45