ia64/xen-unstable

view tools/libaio/harness/cases/5.t @ 10736:2937703f0ed0

Added blktap support. Includes kernel driver (enabled as CONFIG_XEN_BLKDEV_TAP=y) and userspace tools. The userspace deamon (blktapctrl) is enabled by default when xend is activated. For further information on using and configuring blktap see tools/blktap/README.
author jchesterfield@dhcp92.uk.xensource.com
date Thu Jul 13 10:13:26 2006 +0100 (2006-07-13)
parents
children
line source
1 /* 5.t
2 - Write from a mmap() of the same file. (5.t)
3 */
4 #include "aio_setup.h"
5 #include <sys/mman.h>
7 int test_main(void)
8 {
9 int page_size = getpagesize();
10 #define SIZE 512
11 char *buf;
12 int rwfd;
13 int status = 0, res;
15 rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1);
16 res = ftruncate(rwfd, 512); assert(res == 0);
18 buf = mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, rwfd, 0);
19 assert(buf != (char *)-1);
21 status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE);
22 status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE);
24 res = munmap(buf, page_size); assert(res == 0);
25 buf = mmap(0, page_size, PROT_READ|PROT_WRITE, MAP_SHARED, rwfd, 0);
26 assert(buf != (char *)-1);
28 status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE);
29 status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE);
31 res = munmap(buf, page_size); assert(res == 0);
32 buf = mmap(0, page_size, PROT_READ, MAP_SHARED, rwfd, 0);
33 assert(buf != (char *)-1);
35 status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, SIZE);
36 status |= attempt_rw(rwfd, buf, SIZE, 0, READ, -EFAULT);
38 res = munmap(buf, page_size); assert(res == 0);
39 buf = mmap(0, page_size, PROT_WRITE, MAP_SHARED, rwfd, 0);
40 assert(buf != (char *)-1);
42 status |= attempt_rw(rwfd, buf, SIZE, 0, READ, SIZE);
43 status |= attempt_rw(rwfd, buf, SIZE, 0, WRITE, -EFAULT);
45 return status;
46 }