Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167456023
D58869.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D58869.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D58869: usb: skip root_mount_hold when root is not on USB
Attached
Detach File
Event Timeline
Log In to Comment