Fix link errors with GCC 10 and binutils 2.34 on Fedora
[pintos-anon] / src / tests / filesys / base / child-syn-read.c
1 /* Child process for syn-read test.
2    Reads the contents of a test file a byte at a time, in the
3    hope that this will take long enough that we can get a
4    significant amount of contention in the kernel file system
5    code. */
6
7 #include <random.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <syscall.h>
11 #include "tests/lib.h"
12 #include "tests/filesys/base/syn-read.h"
13
14 static char buf[BUF_SIZE];
15
16 int
17 main (int argc, const char *argv[]) 
18 {
19   int child_idx;
20   int fd;
21   size_t i;
22
23   test_name = "child-syn-read";
24   quiet = true;
25   
26   CHECK (argc == 2, "argc must be 2, actually %d", argc);
27   child_idx = atoi (argv[1]);
28
29   random_init (0);
30   random_bytes (buf, sizeof buf);
31
32   CHECK ((fd = open (file_name)) > 1, "open \"%s\"", file_name);
33   for (i = 0; i < sizeof buf; i++) 
34     {
35       char c;
36       CHECK (read (fd, &c, 1) > 0, "read \"%s\"", file_name);
37       compare_bytes (&c, buf + i, 1, i, file_name);
38     }
39   close (fd);
40
41   return child_idx;
42 }
43