I'm emulating a certain functionality of kqueue to handle events in my Centos box (I'm porting some code from FreeBSD), but I'm failing to understand the purpose of void *udata
in struct kevent
:
struct kevent {
uintptr_t ident; /* identifier for this event */
short filter; /* filter for event */
u_short flags; /* action flags for kqueue */
u_int fflags; /* filter flag value */
intptr_t data; /* filter data value */
void *udata; /* opaque user data identifier */
};
I've tried searching, but the longest form of literature I could find about this field is "Opaque user-defined value passed through the kernel unchanged." Which is not helping much.
Can anyone please explain to me clearly what this field is? And what someone could use it for?
The udata field is passed in and out of the kernel unchanged, and is not used in any way. The usage of this field is entirely application dependent, and is provided as a way to efficiently implement a function dispatch routine, or otherwise add an application identifier to the kevent structure.
for complete reference, please check out the following paper: