diff options
| author | m00nbsd <42475391+m00nbsd@users.noreply.github.com> | 2020-06-13 12:10:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-13 12:10:16 +0200 |
| commit | dbce178a0e6997a799ba38247059dcb8213f4572 (patch) | |
| tree | 44c8bf22f223f1a9f2d3f37012fdbf0d9bb0a624 /executor/common_bsd.h | |
| parent | 205b2ba41849749529bce61d21862f8c86ed12a4 (diff) | |
sys/netbsd: support multiple vHCI buses (#1822)
Diffstat (limited to 'executor/common_bsd.h')
| -rw-r--r-- | executor/common_bsd.h | 22 |
1 files changed, 20 insertions, 2 deletions
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 <dirent.h> 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 |
