e5b5b95d2475b2f2a8d71a7f6c87a3cb9815b02a
[pintos-anon] / grading / userprog / write-zero.c
1 #include <stdio.h>
2 #include <syscall.h>
3
4 int
5 main (void) 
6 {
7   int handle, byte_cnt;
8   char buf;
9   printf ("(write-zero) begin\n");
10
11   handle = open ("sample.txt");
12   if (handle < 2)
13     printf ("(write-zero) fail: open() returned %d\n", handle);
14
15   buf = 123;
16   byte_cnt = write (handle, &buf, 0);
17   if (byte_cnt != 0)
18     printf ("(write-zero) fail: write() returned %d instead of 0\n", byte_cnt);
19   
20   printf ("(write-zero) end\n");
21   return 0;
22 }