Added translation layer for all things that might be different between newlib and...
[akaros.git] / tools / syscall_server / pipe_init.c
1 #include <fcntl.h>
2 #include <stdio.h>
3
4 // These definitions seem backwards, but they are not.
5 //  They are assigned from the persepctive of how qemu sees them
6 #define SYSCALL_SERVER_PIPE_IN  ".syscall_server_pipe.out"
7 #define SYSCALL_SERVER_PIPE_OUT ".syscall_server_pipe.in"
8
9 int init_syscall_server(int* fd_read, int* fd_write) {
10
11         printf("Waiting for other end of pipe to connect...\n");
12         int write = open(SYSCALL_SERVER_PIPE_OUT, O_WRONLY);
13         if(write < 0)
14                 return write;
15
16         int read = open(SYSCALL_SERVER_PIPE_IN, O_RDONLY);
17         if(read < 0) {
18                 close(write);
19                 return read;
20         }
21
22     *fd_read = read;
23         *fd_write = write;
24     return read+write;
25 }