ia64/xen-unstable

view tools/libaio/harness/cases/6.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 /* 6.t
2 - huge reads (pinned pages) (6.t)
3 - huge writes (6.t)
4 */
5 #include "aio_setup.h"
6 #include <sys/mman.h>
8 long getmemsize(void)
9 {
10 FILE *f = fopen("/proc/meminfo", "r");
11 long size;
12 int gotit = 0;
13 char str[256];
15 assert(f != NULL);
16 while (NULL != fgets(str, 255, f)) {
17 str[255] = 0;
18 if (0 == memcmp(str, "MemTotal:", 9)) {
19 if (1 == sscanf(str + 9, "%ld", &size)) {
20 gotit = 1;
21 break;
22 }
23 }
24 }
25 fclose(f);
27 assert(gotit != 0);
28 return size;
29 }
31 int test_main(void)
32 {
33 char *buf;
34 int rwfd;
35 int status = 0, res;
36 long size;
38 size = getmemsize();
39 printf("size = %ld\n", size);
40 assert(size >= (16 * 1024));
41 if (size > (768 * 1024))
42 size = 768 * 1024;
43 size *= 1024;
45 rwfd = open("testdir/rwfile", O_RDWR); assert(rwfd != -1);
46 res = ftruncate(rwfd, 0); assert(res == 0);
47 buf = malloc(size); assert(buf != NULL);
49 //memset(buf, 0, size);
50 status |= attempt_rw(rwfd, buf, size, 0, WRITE, size);
51 status |= attempt_rw(rwfd, buf, size, 0, READ, size);
53 //res = ftruncate(rwfd, 0); assert(res == 0);
55 return status;
56 }