Added serial hw flow control, rest of the file syscalls, updated tests
[akaros.git] / user / apps / parlib / file_io.c
1 #include <stdlib.h>
2 #include <sys/types.h>
3 #include <sys/stat.h>
4 #include <fcntl.h>
5 #include <stdio.h>
6 #include <unistd.h>
7
8 int main(int argc, char** argv)
9 {
10         printf("Welcome to the ROS newlib test suite!\nEnter at you're own risk....\n");
11
12         printf("Size of stat struct: %u\n", sizeof(struct stat));
13
14         int fd = open("./test/matrix", O_RDWR, 0);
15         char buf[100];
16         int read_amt = read(fd, buf, 100);
17         printf("FD: %d\n", fd);
18         printf("read_amt: %d\n", read_amt);
19         printf("read: %s\n", buf);
20
21         char buf2[] = "NANWAN!\n";
22
23         int fd = open("./test/nanwan", O_RDWR | O_CREAT, 
24                       S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH);
25         
26         lseek(fd, 0, SEEK_END); 
27
28         int write_amt = write(fd, buf2, sizeof(buf2) -1);
29         printf("write_amt: %d\n", write_amt);        
30         printf("wrote: %s\n", buf2);
31
32         unlink ("./test/nanwan_link");
33
34
35         link("./test/nanwan", "./test/nanwan_link");
36         unlink("./test/to_delete");
37
38
39         return 0;
40 }