Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7143f7a1 authored by Roland Dreier's avatar Roland Dreier Committed by Greg Kroah-Hartman
Browse files

driver core: Convert '/' to '!' in dev_set_name()



Commit 3ada8b7e ("block: struct device - replace bus_id with dev_name(),
dev_set_name()") deleted the code in register_disk() that changed a '/'
to a '!' in the device name when registering a disk, but dev_set_name()
does not perform this conversion.

This leads to amusing problems with disks that have '/' in their names:
for example a failure to boot with the root partition on a cciss device,
even though the kernel says it knows about the root device:

    VFS: Cannot open root device "cciss/c0d0p6" or unknown-block(0,0)
    Please append a correct "root=" boot option; here are the available partitions:
    6800        71652960 cciss/c0d0 driver: cciss
      6802               1 cciss/c0d0p2
      6805         2931831 cciss/c0d0p5
      6806        34354908 cciss/c0d0p6
    6810        71652960 cciss/c0d1 driver: cciss

Fix this by adding code to change '/' to '!' in dev_set_name() to handle
this until dev_set_name() is converted to use kobject_set_name().

Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
Acked-by: default avatarKay Sievers <kay.sievers@vrfy.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent f3b8436a
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -777,10 +777,16 @@ static void device_remove_class_symlinks(struct device *dev)
int dev_set_name(struct device *dev, const char *fmt, ...)
int dev_set_name(struct device *dev, const char *fmt, ...)
{
{
	va_list vargs;
	va_list vargs;
	char *s;


	va_start(vargs, fmt);
	va_start(vargs, fmt);
	vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
	vsnprintf(dev->bus_id, sizeof(dev->bus_id), fmt, vargs);
	va_end(vargs);
	va_end(vargs);

	/* ewww... some of these buggers have / in the name... */
	while ((s = strchr(dev->bus_id, '/')))
		*s = '!';

	return 0;
	return 0;
}
}
EXPORT_SYMBOL_GPL(dev_set_name);
EXPORT_SYMBOL_GPL(dev_set_name);