blob: f7c819543560e85f51a3b957a35b2be628e5355d (
plain)
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
35
36
37
38
39
40
41
42
43
44
|
#include "net9p.h"
#include "net9p_defs.h"
#include "netio.h"
#define MAX_MSG_SIZE 1024
int read_msg(int conn, uint16_t *out_tag, void **out_body) {
uint8_t buf[MAX_MSG_SIZE];
size_t todo = 7, done = 0;
while (done < todo) {
ssize_t r = netio_read(conn, buf, 7);
if (r < 0)
return r;
done += r;
}
todo = docode_u32le(buf);
if (todo < 7)
return -EINVAL;
while (done < todo) {
ssize_t r = netio_read(conn, buf, 7);
if (r < 0)
return r;
done += r;
}
return v9fs_unmarshal_msg(buf, out_tag, out_body);
}
void net9p_cr(void *_arg) {
int sock = *((int *)_arg);
cr_begin();
for (;;) {
int conn = netio_accept(sock);
if (conn < 0) {
error(0, -conn, "netio_accept");
continue;
}
}
cr_end();
}
|