BNX2X: IRQs implemented
[akaros.git] / tools / syscall_server / pipe.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 }
26
27 int read_syscall_server(int fd, char* buf, int len) {
28         return read(fd, buf, len);
29 }
30
31 int write_syscall_server(int fd, char* buf, int len, int bytes_to_follow) {
32         return write(fd, buf, len);
33 }
34
35