From dbce178a0e6997a799ba38247059dcb8213f4572 Mon Sep 17 00:00:00 2001 From: m00nbsd <42475391+m00nbsd@users.noreply.github.com> Date: Sat, 13 Jun 2020 12:10:16 +0200 Subject: sys/netbsd: support multiple vHCI buses (#1822) --- executor/common_bsd.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'executor/common_bsd.h') diff --git a/executor/common_bsd.h b/executor/common_bsd.h index 82aef4211..070c512bf 100644 --- a/executor/common_bsd.h +++ b/executor/common_bsd.h @@ -17,10 +17,28 @@ #include "common_usb_netbsd.h" #endif #if SYZ_EXECUTOR || SYZ_USB +#include static void setup_usb(void) { - if (chmod("/dev/vhci", 0666)) - fail("failed to chmod /dev/vhci"); + struct dirent* ent; + char path[1024]; + DIR* dir; + + dir = opendir("/dev"); + if (dir == NULL) + fail("failed to open /dev"); + + while ((ent = readdir(dir)) != NULL) { + if (ent->d_type != DT_CHR) + continue; + if (strncmp(ent->d_name, "vhci", 4)) + continue; + snprintf(path, sizeof(path), "/dev/%s", ent->d_name); + if (chmod(path, 0666)) + fail("failed to chmod %s", path); + } + + closedir(dir); } #endif -- cgit mrf-deployment