6 #include "posix-compat.h"
8 #include "../lib/arc4.h"
9 #include "../lib/cksum.h"
11 #define SIZE (63 * 1024) /* Max file size. */
12 static char *buf = (char *) 0x10000000;
17 static struct arc4 arc4;
18 static bool inited = false;
21 arc4_init (&arc4, "quux", 4);
30 static unsigned long x;
31 arc4_crypt (get_key (), &x, sizeof x);
40 for (i = 0; i < SIZE; i++)
42 size_t j = i + random_ulong () % (SIZE - i);
55 printf ("(mmap-shuffle) begin\n");
57 /* Create file, mmap. */
58 if (!create ("buffer", SIZE))
60 printf ("(mmap-shuffle) create() failed\n");
67 printf ("(mmap-shuffle) open() failed\n");
71 if (!mmap (fd, buf, SIZE))
73 printf ("(mmap-shuffle) mmap() failed\n");
78 for (i = 0; i < SIZE; i++)
80 printf ("(mmap-shuffle) init: cksum=%lu\n", cksum (buf, SIZE));
82 /* Shuffle repeatedly. */
83 for (i = 0; i < 10; i++)
86 printf ("(mmap-shuffle) shuffle %zu: cksum=%lu\n",
87 i, cksum (buf, SIZE));
91 printf ("(mmap-shuffle) end\n");