summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2017-03-30 20:09:49 +0000
committerdchagin <dchagin@FreeBSD.org>2017-03-30 20:09:49 +0000
commited7b42750439315deefda8e58958477654ce018c (patch)
tree9d6370c46bf737934ad9bf8148c5058f4269a124
parent9a78265c32475a07e7c0b167183d65908ac80eef (diff)
downloadFreeBSD-src-ed7b42750439315deefda8e58958477654ce018c.zip
FreeBSD-src-ed7b42750439315deefda8e58958477654ce018c.tar.gz
MFC r314343:
Unify eventfd ioctl method and use it for other similar interfaces.
-rw-r--r--sys/compat/linux/linux_event.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c
index f7471b2..2ce489a 100644
--- a/sys/compat/linux/linux_event.c
+++ b/sys/compat/linux/linux_event.c
@@ -177,7 +177,7 @@ static struct fileops timerfdops = {
.fo_read = timerfd_read,
.fo_write = invfo_rdwr,
.fo_truncate = invfo_truncate,
- .fo_ioctl = invfo_ioctl,
+ .fo_ioctl = eventfd_ioctl,
.fo_poll = timerfd_poll,
.fo_kqfilter = timerfd_kqfilter,
.fo_stat = timerfd_stat,
@@ -760,7 +760,7 @@ eventfd_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
mtx_lock(&efd->efd_lock);
retry:
if (efd->efd_count == 0) {
- if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) {
+ if ((fp->f_flag & FNONBLOCK) != 0) {
mtx_unlock(&efd->efd_lock);
return (EAGAIN);
}
@@ -811,7 +811,7 @@ eventfd_write(struct file *fp, struct uio *uio, struct ucred *active_cred,
mtx_lock(&efd->efd_lock);
retry:
if (UINT64_MAX - efd->efd_count <= count) {
- if ((efd->efd_flags & LINUX_O_NONBLOCK) != 0) {
+ if ((fp->f_flag & FNONBLOCK) != 0) {
mtx_unlock(&efd->efd_lock);
/* Do not not return the number of bytes written */
uio->uio_resid += sizeof(eventfd_t);
@@ -927,19 +927,18 @@ static int
eventfd_ioctl(struct file *fp, u_long cmd, void *data,
struct ucred *active_cred, struct thread *td)
{
- struct eventfd *efd;
- efd = fp->f_data;
- if (fp->f_type != DTYPE_LINUXEFD || efd == NULL)
+ if (fp->f_data == NULL || (fp->f_type != DTYPE_LINUXEFD &&
+ fp->f_type != DTYPE_LINUXTFD))
return (EINVAL);
switch (cmd)
{
case FIONBIO:
- if (*(int *)data)
- efd->efd_flags |= LINUX_O_NONBLOCK;
+ if ((*(int *)data))
+ atomic_set_int(&fp->f_flag, FNONBLOCK);
else
- efd->efd_flags &= ~LINUX_O_NONBLOCK;
+ atomic_clear_int(&fp->f_flag, FNONBLOCK);
case FIOASYNC:
return (0);
default:
OpenPOWER on IntegriCloud