From: Paolo Bonzini <pbonzini@redhat.com> Date: Wed, 4 Aug 2010 15:24:13 -0400 Subject: [virt] xenbus: implement O_NONBLOCK Message-id: <1280935454-22447-2-git-send-email-pbonzini@redhat.com> Patchwork-id: 27383 O-Subject: [RHEL5.5 PATCH] xenbus: implement O_NONBLOCK Bugzilla: 470801 RH-Acked-by: Andrew Jones <drjones@redhat.com> Bugzilla: 470801 Upstream status: http://xenbits.xensource.com/linux-2.6.18-xen.hg?rev/1024 Brew build: https://brewweb.devel.redhat.com/taskinfo?taskID=2651766 This patch implements O_NONBLOCK for /proc/xen/xenbus. Since no locking is required, it is a simple matter of checking the FIFO and returning -EAGAIN if there's nothing in the queue (our implementation is slightly different from upstream). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> diff --git a/drivers/xen/xenbus/xenbus_dev.c b/drivers/xen/xenbus/xenbus_dev.c index c630557..2471396 100644 --- a/drivers/xen/xenbus/xenbus_dev.c +++ b/drivers/xen/xenbus/xenbus_dev.c @@ -89,6 +89,10 @@ static ssize_t xenbus_dev_read(struct file *filp, struct xenbus_dev_data *u = filp->private_data; int i; + if (u->read_prod == u->read_cons && + (filp->f_flags & O_NONBLOCK)) + return -EAGAIN; + if (wait_event_interruptible(u->read_waitq, u->read_prod != u->read_cons)) return -EINTR;