aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_usb_netbsd.h
diff options
context:
space:
mode:
authorm00nbsd <42475391+m00nbsd@users.noreply.github.com>2020-06-13 12:10:16 +0200
committerGitHub <noreply@github.com>2020-06-13 12:10:16 +0200
commitdbce178a0e6997a799ba38247059dcb8213f4572 (patch)
tree44c8bf22f223f1a9f2d3f37012fdbf0d9bb0a624 /executor/common_usb_netbsd.h
parent205b2ba41849749529bce61d21862f8c86ed12a4 (diff)
sys/netbsd: support multiple vHCI buses (#1822)
Diffstat (limited to 'executor/common_usb_netbsd.h')
-rw-r--r--executor/common_usb_netbsd.h25
1 files changed, 9 insertions, 16 deletions
diff --git a/executor/common_usb_netbsd.h b/executor/common_usb_netbsd.h
index c6936993f..9ce8f72dc 100644
--- a/executor/common_usb_netbsd.h
+++ b/executor/common_usb_netbsd.h
@@ -159,7 +159,11 @@ struct usb_qualifier_descriptor {
static int vhci_open(void)
{
- return open("/dev/vhci", O_RDWR);
+ char path[1024];
+
+ snprintf(path, sizeof(path), "/dev/vhci%llu", procid);
+
+ return open(path, O_RDWR);
}
static int vhci_setport(int fd, u_int port)
@@ -214,31 +218,22 @@ static volatile long syz_usb_connect_impl(uint64 speed, uint64 dev_len,
lookup_connect_out_response_t lookup_connect_response_out)
{
struct usb_device_index* index;
- int portnum, fd, rv;
+ int fd, rv;
bool done;
- portnum = procid + 1;
-
debug("syz_usb_connect: dev: %p\n", dev);
if (!dev) {
debug("syz_usb_connect: dev is null\n");
return -1;
}
- if (portnum != 1) {
- /* For now, we support only one proc. */
- debug("syz_usb_connect: not proc1 %d\n", (int)procid);
- return -1;
- }
debug("syz_usb_connect: device data:\n");
debug_dump_data(dev, dev_len);
fd = vhci_open();
if (fd < 0) {
- debug("syz_usb_connect: vhci_open failed with %d\n", fd);
- return -1;
+ fail("syz_usb_connect: vhci_open failed with %d", errno);
}
- debug("syz_usb_connect: vhci_open success\n");
index = add_usb_index(fd, dev, dev_len);
if (!index) {
@@ -251,12 +246,10 @@ static volatile long syz_usb_connect_impl(uint64 speed, uint64 dev_len,
NONFAILING(analyze_usb_device(index));
#endif
- rv = vhci_setport(fd, portnum);
+ rv = vhci_setport(fd, 1);
if (rv != 0) {
- debug("syz_usb_connect: vhci_setport failed with %d\n", rv);
- goto err;
+ fail("syz_usb_connect: vhci_setport failed with %d", errno);
}
- debug("syz_usb_connect: vhci_setport success\n");
rv = vhci_usb_attach(fd);
if (rv != 0) {