Add FD tap infrastructure (XCC)
[akaros.git] / kern / include / fdtap.h
1 /* Copyright (c) 2015 Google Inc
2  * Barret Rhoden <brho@cs.berkeley.edu>
3  * See LICENSE for details.
4  *
5  * FD taps.  Allows the user to receive events when certain things happen to an
6  * FD's underlying disk/device file. */
7
8 #ifndef ROS_KERN_FDTAP_H
9 #define ROS_KERN_FDTAP_H
10
11 #include <ros/fdtap.h>
12 #include <sys/queue.h>
13 #include <kref.h>
14
15 struct proc;
16 struct event_queue;
17 struct chan;
18
19 struct fd_tap;
20 SLIST_HEAD(fdtap_slist, fd_tap);
21
22 struct fd_tap {
23         SLIST_ENTRY(fd_tap)                     link;   /* for device use */
24         struct kref                                     kref;
25         struct chan                                     *chan;
26         int                                                     fd;
27         int                                                     filter;
28         struct proc                                     *proc;
29         struct event_queue                      *ev_q;
30         int                                                     ev_id;
31         void                                            *data;
32 };
33
34 int add_fd_tap(struct proc *p, struct fd_tap_req *tap_req);
35 int remove_fd_tap(struct proc *p, int fd);
36 int fire_tap(struct fd_tap *tap, int filter);
37
38 #endif /* ROS_KERN_FDTAP_H */