374d405f06129c23cc99696dbd01b04a8c515129
[pintos-anon] / grading / userprog / open-boundary.c
1 #include <inttypes.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include <syscall.h>
5
6 static char *
7 mk_boundary_string (const char *src) 
8 {
9   static char dst[8192];
10   char *p = dst + (4096 - (uintptr_t) dst % 4096 - strlen (src) / 2);
11   strlcpy (p, src, 4096);
12   return p;
13 }
14
15 int
16 main (void) 
17 {
18   int handle;
19
20   printf ("(open-boundary) begin\n");
21   handle = open (mk_boundary_string ("sample.txt"));
22   if (handle < 2)
23     printf ("(open-boundary) fail: open() returned %d\n", handle);
24   printf ("(open-boundary) end\n");
25   return 0;
26 }