6 #include "posix-compat.h"
8 #include "../lib/arc4.h"
9 #include "../lib/cksum.h"
11 /* This is the max file size for an older version of the Pintos
12 file system that had 126 direct blocks each pointing to a
13 single disk sector. We could raise it now. */
14 #define SIZE (126 * 512)
16 static char *buf = (char *) 0x10000000;
21 static struct arc4 arc4;
22 static bool inited = false;
25 arc4_init (&arc4, "quux", 4);
34 static unsigned long x;
35 arc4_crypt (get_key (), &x, sizeof x);
44 for (i = 0; i < SIZE; i++)
46 size_t j = i + random_ulong () % (SIZE - i);
59 printf ("(mmap-shuffle) begin\n");
61 /* Create file, mmap. */
62 if (!create ("buffer", SIZE))
64 printf ("(mmap-shuffle) create() failed\n");
71 printf ("(mmap-shuffle) open() failed\n");
75 if (mmap (fd, buf) == MAP_FAILED)
77 printf ("(mmap-shuffle) mmap() failed\n");
82 for (i = 0; i < SIZE; i++)
84 printf ("(mmap-shuffle) init: cksum=%lu\n", cksum (buf, SIZE));
86 /* Shuffle repeatedly. */
87 for (i = 0; i < 10; i++)
90 printf ("(mmap-shuffle) shuffle %zu: cksum=%lu\n",
91 i, cksum (buf, SIZE));
95 printf ("(mmap-shuffle) end\n");