Fix an OpenBSD backend bug where an existing open file descriptor is
overwritten if a libusb user attempts to open the same ugen(4) device
multiple times. This was observed with sane-backends and broke scanning.
Fix from stsp@openbsd.org
Closes #763
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
char devnode[16];
if (dpriv->devname) {
+ int fd;
/*
* Only open ugen(4) attached devices read-write, all
* read-only operations are done through the bus node.
*/
snprintf(devnode, sizeof(devnode), DEVPATH "%s.00",
dpriv->devname);
- dpriv->fd = open(devnode, O_RDWR);
- if (dpriv->fd < 0)
+ fd = open(devnode, O_RDWR);
+ if (fd < 0)
return _errno_to_libusb(errno);
+ dpriv->fd = fd;
usbi_dbg("open %s: fd %d", devnode, dpriv->fd);
}
-#define LIBUSB_NANO 11527
+#define LIBUSB_NANO 11528