[PATCH] check for errors when reading from /dev/uioX

  • From: Robert Millan <rmh@xxxxxxxxxxx>
  • To: rumpkernel-users@xxxxxxxxxxxxx
  • Date: Sun, 16 Aug 2015 02:40:55 +0200


Hi,

Currently the intrthread loop just checks the number of bytes read, but
a quick peek at the Linux source shows that /dev/uioX has a few failure
conditions. Attached patch tries to do a better job at detecting and
reporting them.

--
Robert Millan
Index: rumpkernel-0~20150715/pci-userspace/src-linux-uio/pci_user-uio_linux.c
===================================================================
--- rumpkernel-0~20150715.orig/pci-userspace/src-linux-uio/pci_user-uio_linux.c
2015-07-23 22:57:29.000000000 +0200
+++ rumpkernel-0~20150715/pci-userspace/src-linux-uio/pci_user-uio_linux.c
2015-08-16 02:25:40.778896737 +0200
@@ -187,6 +187,7 @@
struct irq *irq = arg;
const unsigned device = irq->device;
int val;
+ int ret;

rumpuser_component_kthread();
for (;;) {
@@ -196,7 +197,10 @@
val &= ~0x400;
rumpcomp_pci_confwrite(0, device, 0, 0x04, val);
}
- if (read(irq->fd, &val, sizeof(val)) > 0) {
+ ret = read(irq->fd, &val, sizeof(val));
+ if (ret == -1) {
+ err(1, "read from UIO device %d", irq->device);
+ } else if (ret > 0) {
//printf("INTERRUPT!\n");
rumpuser_component_schedule(NULL);
irq->handler(irq->data);

Other related posts:

  • » [PATCH] check for errors when reading from /dev/uioX - Robert Millan