d_poll function for character device

Aaci

New Member


Messages: 3

Is anyone familiar with the d_poll function of the character devices?

Code:
#include <sys/conf.h>
typedef int d_poll_t(struct cdev *dev, int events, struct thread *td);
I know it is the one being called when a device file was passed into select(2) system call, but how do the "events" argument and the return value work? I wrote a utility to "select" a char device file which I've implemented the d_poll function, but the "events" flag seems to be wired...I printed the events argument inside the d_poll of my implementation, and on a "select for read" it was passed in as 0x58 (POLLERR | POLLHUP | POLLRDNORM); on a "select for write" it was 0x1C (POLLHUP | POLLERR | POLLOUT).

When I return 0 (I thought the return value was an error code as usual), selecting for write just freezes; but when I return POLLOUT the select call returns normally. Selecting for read always returns normally I despite I returned EINVAL (decimal 22, which does not contain POLLIN). Anyone knows how this d_poll should be implemented correctly?
 
Top