2 * Copyright (c) 2009 Mark Heily <mark@heily.com>
3 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * $FreeBSD SVN Revision 197533$
33 #include <sys/types.h>
38 #include <sys/queue.h>
39 #include <sys/types.h>
46 #define EVFILT_READ (-1)
47 #define EVFILT_WRITE (-2)
48 #define EVFILT_AIO (-3) /* attached to aio requests */
49 #define EVFILT_VNODE (-4) /* attached to vnodes */
50 #define EVFILT_PROC (-5) /* attached to struct proc */
51 #define EVFILT_SIGNAL (-6) /* attached to struct proc */
52 #define EVFILT_TIMER (-7) /* timers */
53 #define EVFILT_NETDEV (-8) /* network devices */
54 #define EVFILT_FS (-9) /* filesystem events */
55 #define EVFILT_LIO (-10) /* attached to lio requests */
56 #define EVFILT_USER (-11) /* User events */
57 #define EVFILT_SYSCOUNT 11
59 #define EV_SET(kevp_, a, b, c, d, e, f) do { \
60 struct kevent *kevp = (kevp_); \
61 (kevp)->ident = (a); \
62 (kevp)->filter = (b); \
63 (kevp)->flags = (c); \
64 (kevp)->fflags = (d); \
66 (kevp)->udata = (f); \
70 uintptr_t ident; /* identifier for this event */
71 short filter; /* filter for event */
75 void *udata; /* opaque user data identifier */
79 #define EV_ADD 0x0001 /* add event to kq (implies enable) */
80 #define EV_DELETE 0x0002 /* delete event from kq */
81 #define EV_ENABLE 0x0004 /* enable event */
82 #define EV_DISABLE 0x0008 /* disable event (not reported) */
85 #define EV_ONESHOT 0x0010 /* only report one occurrence */
86 #define EV_CLEAR 0x0020 /* clear event state after reporting */
87 #define EV_RECEIPT 0x0040 /* force EV_ERROR on success, data=0 */
88 #define EV_DISPATCH 0x0080 /* disable event after reporting */
90 #define EV_SYSFLAGS 0xF000 /* reserved by system */
91 #define EV_FLAG1 0x2000 /* filter-specific flag */
94 #define EV_EOF 0x8000 /* EOF detected */
95 #define EV_ERROR 0x4000 /* error, data contains errno */
98 * data/hint flags/masks for EVFILT_USER
100 * On input, the top two bits of fflags specifies how the lower twenty four
101 * bits should be applied to the stored value of fflags.
103 * On output, the top two bits will always be set to NOTE_FFNOP and the
104 * remaining twenty four bits will contain the stored fflags value.
106 #define NOTE_FFNOP 0x00000000 /* ignore input fflags */
107 #define NOTE_FFAND 0x40000000 /* AND fflags */
108 #define NOTE_FFOR 0x80000000 /* OR fflags */
109 #define NOTE_FFCOPY 0xc0000000 /* copy fflags */
110 #define NOTE_FFCTRLMASK 0xc0000000 /* masks for operations */
111 #define NOTE_FFLAGSMASK 0x00ffffff
113 #define NOTE_TRIGGER 0x01000000 /* Cause the event to be
114 triggered for output. */
117 * data/hint flags for EVFILT_{READ|WRITE}
119 #define NOTE_LOWAT 0x0001 /* low water mark */
120 #undef NOTE_LOWAT /* Not supported on Linux */
123 * data/hint flags for EVFILT_VNODE
125 #define NOTE_DELETE 0x0001 /* vnode was removed */
126 #define NOTE_WRITE 0x0002 /* data contents changed */
127 #define NOTE_EXTEND 0x0004 /* size increased */
128 #define NOTE_ATTRIB 0x0008 /* attributes changed */
129 #define NOTE_LINK 0x0010 /* link count changed */
130 #define NOTE_RENAME 0x0020 /* vnode was renamed */
131 #define NOTE_REVOKE 0x0040 /* vnode access was revoked */
132 #undef NOTE_REVOKE /* Not supported on Linux */
135 * data/hint flags for EVFILT_PROC
137 #define NOTE_EXIT 0x80000000 /* process exited */
138 #define NOTE_FORK 0x40000000 /* process forked */
139 #define NOTE_EXEC 0x20000000 /* process exec'd */
140 #define NOTE_PCTRLMASK 0xf0000000 /* mask for hint bits */
141 #define NOTE_PDATAMASK 0x000fffff /* mask for pid */
143 /* additional flags for EVFILT_PROC */
144 #define NOTE_TRACK 0x00000001 /* follow across forks */
145 #define NOTE_TRACKERR 0x00000002 /* could not track child */
146 #define NOTE_CHILD 0x00000004 /* am a child process */
149 * data/hint flags for EVFILT_NETDEV
151 #define NOTE_LINKUP 0x0001 /* link is up */
152 #define NOTE_LINKDOWN 0x0002 /* link is down */
153 #define NOTE_LINKINV 0x0004 /* link state is invalid */
155 /* KLUDGE: This is from <sys/mount.h> on FreeBSD and is used by
156 the EVFILT_FS filter. */
158 #define VQ_NOTRESP 0x0001 /* server down */
159 #define VQ_NEEDAUTH 0x0002 /* server bad auth */
160 #define VQ_LOWDISK 0x0004 /* we're low on space */
161 #define VQ_MOUNT 0x0008 /* new filesystem arrived */
162 #define VQ_UNMOUNT 0x0010 /* filesystem has left */
163 #define VQ_DEAD 0x0020 /* filesystem is dead, needs force unmount */
164 #define VQ_ASSIST 0x0040 /* filesystem needs assistance from external
166 #define VQ_NOTRESPLOCK 0x0080 /* server lockd down */
175 int kevent(int kq, const struct kevent *changelist, int nchanges,
176 struct kevent *eventlist, int nevents,
177 const struct timespec *timeout);
182 #endif /* !__KERNEL__* */
184 #endif /* !_SYS_EVENT_H_ */