Get rid of unnecessary barrier. Improve comment.
[pintos-anon] / grading / vm / mmap-close.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "../lib/arc4.h"
4 #include "sample.inc"
5 #ifdef PINTOS
6 #include <syscall.h>
7 #else
8 #include "posix-compat.h"
9 #endif
10
11 #define ACTUAL ((void *) 0x10000000)
12
13 int
14 main (void) 
15 {
16   int fd;
17   mapid_t map;
18
19   printf ("(mmap-close) begin\n");
20
21   fd = open ("sample.txt");
22   if (fd < 0) 
23     {
24       printf ("(mmap-close) open() failed\n");
25       return 1;
26     }
27
28   map = mmap (fd, ACTUAL);
29   if (map == MAP_FAILED)
30     {
31       printf ("(mmap-close) mmap() failed\n");
32       return 1;
33     }
34
35   close (fd);
36
37   if (memcmp (ACTUAL, sample, strlen (sample)))
38     {
39       printf ("(mmap-close) read of mmap'd file reported bad data\n");
40       return 1;
41     }
42
43   munmap (map);
44
45   /* Done. */
46   printf ("(mmap-close) end\n");
47
48   return 0;
49 }