Tamer
C++ language extensions for event-driven programming
Loading...
Searching...
No Matches
fdhmsg.hh
1#ifndef TAMER_FDHELP_HH
2#define TAMER_FDHELP_HH 1
3#include <unistd.h>
4#include <stdint.h>
5#include <sys/types.h>
6#include <sys/stat.h>
7#include <fcntl.h>
8
9#define FDH_CLONE 100
10//#define FDH_KILL 101
11#define FDH_OPEN 102
12#define FDH_STAT 103
13#define FDH_READ 104
14#define FDH_WRITE 105
15
16//TODO add old unices support (if needed) i.e. msg_control -> msg_accrights
17
18/* clone
19 * > msg: req
20 * < msg: errno | pid; [anc: fd]
21 *
22 * kill
23 * > msg: req
24 *
25 * open
26 * > msg: req | int (flag) | mode | filename
27 * < msg: errno; [anc: fd]
28 *
29 * stat
30 * > msg: req, anc: fd
31 * < msg: errno | [stat]
32 *
33 * read
34 * > msg: req | size; anc: fd
35 * < sendfile: pipe, fd, NULL, size
36 *
37 * write
38 * > msg: req | size; anc: fd
39 * > write: pipe
40 * < read: pipe -> write: fd
41 */
42
43union fdh_msg {
44 struct {
45 uint8_t req;
46 union {
47 size_t size;
48 int flags;
49 };
50 mode_t mode;
51 } query;
52 struct {
53 int err;
54 pid_t pid;
55 } reply;
56};//stat and fname placed at the end
57
58typedef union fdh_msg fdh_msg;
59
60#define FDH_MSG_SIZE sizeof(union fdh_msg)
61
62int fdh_recv(int fd, int * fd_to_recv, char * buf, size_t len);
63
64#endif /*TAMER_FDHELP_HH*/