Commit cf056a43 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

init: improve the name_to_dev_t interface



name_to_dev_t has a very misleading name, that doesn't make clear
it should only be used by the early init code, and also has a bad
calling convention that doesn't allow returning different kinds of
errors.  Rename it to early_lookup_bdev to make the use case clear,
and return an errno, where -EINVAL means the string could not be
parsed, and -ENODEV means it the string was valid, but there was
no device found for it.

Also stub out the whole call for !CONFIG_BLOCK as all the non-block
root cases are always covered in the caller.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230531125535.676098-14-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent c0c1a7dc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -5453,8 +5453,8 @@

	root=		[KNL] Root filesystem
			Usually this a a block device specifier of some kind,
			see the name_to_dev_t comment in init/do_mounts.c for
			details.
			see the early_lookup_bdev comment in init/do_mounts.c
			for details.
			Alternatively this can be "ram" for the legacy initial
			ramdisk, "nfs" and "cifs" for root on a network file
			system, or "mtd" and "ubi" for mounting from raw flash.
+3 −2
Original line number Diff line number Diff line
@@ -330,8 +330,9 @@ dev_t dm_get_dev_t(const char *path)
{
	dev_t dev;

	if (lookup_bdev(path, &dev))
		dev = name_to_dev_t(path);
	if (lookup_bdev(path, &dev) &&
	    early_lookup_bdev(path, &dev))
		return 0;
	return dev;
}
EXPORT_SYMBOL_GPL(dm_get_dev_t);
+2 −1
Original line number Diff line number Diff line
@@ -147,7 +147,8 @@ static void __init md_setup_drive(struct md_setup_args *args)
		if (p)
			*p++ = 0;

		dev = name_to_dev_t(devname);
		if (early_lookup_bdev(devname, &dev))
			dev = 0;
		if (strncmp(devname, "/dev/", 5) == 0)
			devname += 5;
		snprintf(comp_name, 63, "/dev/%s", devname);
+1 −2
Original line number Diff line number Diff line
@@ -254,8 +254,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size,
			msleep(1000);
		wait_for_device_probe();

		devt = name_to_dev_t(devname);
		if (!devt)
		if (early_lookup_bdev(devname, &devt))
			continue;
		bdev = blkdev_get_by_dev(devt, mode, dev, NULL);
	}
+2 −2
Original line number Diff line number Diff line
@@ -263,9 +263,9 @@ static __init const char *early_boot_devpath(const char *initial_devname)
	 * same scheme to find the device that we use for mounting
	 * the root file system.
	 */
	dev_t dev = name_to_dev_t(initial_devname);
	dev_t dev;

	if (!dev) {
	if (early_lookup_bdev(initial_devname, &dev)) {
		pr_err("failed to resolve '%s'!\n", initial_devname);
		return initial_devname;
	}
Loading