Skip to content

Commit

Permalink
Merge pull request Samsung#1132 from jeongarmy/fs_poll
Browse files Browse the repository at this point in the history
fs/poll: support poll for regular files and block devices
  • Loading branch information
Taejun-Kwon authored Dec 19, 2017
2 parents f66cf16 + 864fc0e commit 280d690
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions os/fs/vfs/fs_poll.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,28 @@ static int poll_fdsetup(int fd, FAR struct pollfd *fds, bool setup)
return ERROR;
}

/* Is a driver registered? Does it support the poll method?
* If not, return -ENOSYS
*/

inode = filep->f_inode;
if (inode && inode->u.i_ops && inode->u.i_ops->poll) {
/* Yes, then setup the poll */

ret = (int)inode->u.i_ops->poll(filep, fds, setup);
if (inode) {
/* Is a driver registered? Does it support the poll method?
* If not, return -ENOSYS
*/

if (INODE_IS_DRIVER(inode) && inode->u.i_ops && inode->u.i_ops->poll) {
/* Yes, then setup the poll */

ret = (int)inode->u.i_ops->poll(filep, fds, setup);
} else if (INODE_IS_MOUNTPT(inode) || INODE_IS_BLOCK(inode)) {
/* Regular files shall always poll TRUE for reading and writing */

if (setup) {
fds->revents |= (fds->events & (POLLIN | POLLOUT));
if (fds->revents != 0) {
sem_post(fds->sem);
}
}
ret = OK;
}
}

return ret;
Expand Down

0 comments on commit 280d690

Please sign in to comment.