Page MenuHomeFreeBSD

D58869.diff
No OneTemporary

D58869.diff

diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c
--- a/sys/dev/usb/controller/usb_controller.c
+++ b/sys/dev/usb/controller/usb_controller.c
@@ -95,6 +95,56 @@
static int usb_no_boot_wait = 0;
SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RDTUN, &usb_no_boot_wait, 0,
"No USB device enumerate waiting at boot.");
+
+static bool
+usb_root_might_be_usb(const char *spec)
+{
+ const char *dev;
+
+ if (spec == NULL || spec[0] == '\0')
+ return (true); /* unknown — be safe */
+
+ /* Only direct device specs can be resolved without tasting. */
+ dev = strchr(spec, ':');
+ if (dev != NULL)
+ return (true); /* zfs:, ufs:, etc., might be USB */
+ dev = spec;
+
+ /* Skip /dev/ prefix. */
+ if (strncmp(dev, "/dev/", 5) == 0)
+ dev += 5;
+
+ /* AHCI and NVMe device nodes are never USB. */
+ if (strncmp(dev, "ada", 3) == 0 ||
+ strncmp(dev, "nda", 3) == 0 ||
+ strncmp(dev, "nvd", 3) == 0)
+ return (false);
+
+ return (true); /* da, GEOM label, unknown, might be USB */
+}
+
+static bool
+usb_root_needs_hold(void)
+{
+ char *env;
+ bool need;
+
+ /* Check vfs.root.mountfrom first. */
+ env = kern_getenv("vfs.root.mountfrom");
+ if (env != NULL) {
+ need = usb_root_might_be_usb(env);
+ freeenv(env);
+ return (need);
+ }
+
+ /* Fall back to compiled-in rootdevnames[]. */
+ extern char *rootdevnames[];
+
+ if (rootdevnames[0] != NULL)
+ return (usb_root_might_be_usb(rootdevnames[0]));
+
+ return (true); /* no hints — wait for USB */
+}
#endif
static int usb_no_suspend_wait = 0;
@@ -177,7 +227,7 @@
}
#if USB_HAVE_ROOT_MOUNT_HOLD
- if (usb_no_boot_wait == 0) {
+ if (usb_no_boot_wait == 0 && usb_root_needs_hold()) {
/* delay vfs_mountroot until the bus is explored */
bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
}

File Metadata

Mime Type
text/plain
Expires
Sat, Aug 22, 9:25 PM (4 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36892298
Default Alt Text
D58869.diff (1 KB)

Event Timeline