Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / vm / mmap-read.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   mapid_t map;
17
18   printf ("(mmap-read) begin\n");
19
20   fd = open ("sample.txt");
21   if (fd < 0) 
22     {
23       printf ("(mmap-read) open() failed\n");
24       return 1;
25     }
26
27   map = mmap (fd, ACTUAL);
28   if (map == MAP_FAILED)
29     {
30       printf ("(mmap-read) mmap() failed\n");
31       return 1;
32     }
33
34   if (memcmp (ACTUAL, sample, strlen (sample)))
35     {
36       printf ("(mmap-read) read of mmap'd file reported bad data\n");
37       return 1;
38     }
39
40   if (!munmap (map))
41     {
42       printf ("(mmap-read) munmap() failed\n");
43       return 1;
44     }
45
46   close (fd);
47
48   /* Done. */
49   printf ("(mmap-read) end\n");
50
51   return 0;
52 }