b0794ec2690146706a720c9af17edc1549e5c6f8
[pintos-anon] / grading / vm / child-mm-wrt.c
1 #include <stdio.h>
2 #include <string.h>
3 #ifdef PINTOS
4 #include <syscall.h>
5 #else
6 #include "posix-compat.h"
7 #endif
8 #include "sample.inc"
9
10 #define ACTUAL ((void *) 0x10000000)
11
12 int
13 main (void) 
14 {
15   int fd;
16
17   printf ("(child-mm-wrt) begin\n");
18
19   /* Write file via mmap. */
20   if (!create ("sample.txt", strlen (sample)))
21     {
22       printf ("(child-mm-wrt) create() failed\n");
23       return 1;
24     }
25   
26   fd = open ("sample.txt");
27   if (fd < 0) 
28     {
29       printf ("(child-mm-wrt) open() failed\n");
30       return 1;
31     }
32
33   if (mmap (fd, ACTUAL) == MAP_FAILED)
34     {
35       printf ("(child-mm-wrt) mmap() failed\n");
36       return 1;
37     }
38   memcpy (ACTUAL, sample, strlen (sample));
39
40   printf ("(child-mm-wrt) end\n");
41
42   return 234;
43 }
44