alarm: Force unset_alarm to grab the CV lock
[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 #pragma once
9
10 #include <ros/fdtap.h>
11 #include <sys/queue.h>
12 #include <kref.h>
13
14 struct proc;
15 struct event_queue;
16 struct chan;
17
18 struct fd_tap;
19 SLIST_HEAD(fdtap_slist, fd_tap);
20
21 struct fd_tap {
22         SLIST_ENTRY(fd_tap)                     link;   /* for device use */
23         struct kref                                     kref;
24         struct chan                                     *chan;
25         int                                                     fd;
26         int                                                     filter;
27         struct proc                                     *proc;
28         struct event_queue                      *ev_q;
29         int                                                     ev_id;
30         void                                            *data;
31 };
32
33 int add_fd_tap(struct proc *p, struct fd_tap_req *tap_req);
34 int remove_fd_tap(struct proc *p, int fd);
35 int fire_tap(struct fd_tap *tap, int filter);