forked from rumpkernel/rumpctrl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadwrite.c
34 lines (28 loc) · 816 Bytes
/
readwrite.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
/*
* _Very_ cheap trick (for purposes of remote clients): assume fd<=2 is
* for stdio/stdout/stderr, so send it the console. All other file
* descriptors go to the rump kernel. This of course should be
* better tracked using something like rumphijack, but the cheap trick
* allows to use most utils via sysproxy now.
*/
int rump___sysimpl_read(int, void *, size_t);
int rump___sysimpl_write(int, const void *, size_t);
int
rumprun_read_wrapper(int fd, void *buf, size_t blen)
{
if (fd <= 2)
return read(fd, buf, blen);
else
return rump___sysimpl_read(fd, buf, blen);
}
int
rumprun_write_wrapper(int fd, const void *buf, size_t blen)
{
if (fd <= 2)
return write(fd, buf, blen);
else
return rump___sysimpl_write(fd, buf, blen);
}