Commit 07d63cbb authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

init: handle ubi/mtd root mounting like all other root types

Assign a Root_Generic magic value for UBI/MTD root and handle the root
mounting in mount_root like all other root types.  Besides making the
code more clear this also means that UBI/MTD root can be used together
with an initrd (not that anyone should care).

Also factor parsing of the root name into a helper now that it can
be easily done and will get more complicated with subsequent patches.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230531125535.676098-11-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 73231b58
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
enum { enum {
Root_NFS = MKDEV(UNNAMED_MAJOR, 255), Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
Root_CIFS = MKDEV(UNNAMED_MAJOR, 254), Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
Root_Generic = MKDEV(UNNAMED_MAJOR, 253),
Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0), Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
}; };
......
...@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name) ...@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name)
case Root_CIFS: case Root_CIFS:
mount_cifs_root(); mount_cifs_root();
break; break;
case Root_Generic:
mount_root_generic(root_device_name, root_device_name,
root_mountflags);
break;
case 0: case 0:
if (root_device_name && root_fs_names && if (root_device_name && root_fs_names &&
mount_nodev_root(root_device_name) == 0) mount_nodev_root(root_device_name) == 0)
...@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name) ...@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name)
} }
} }
static dev_t __init parse_root_device(char *root_device_name)
{
if (!strncmp(root_device_name, "mtd", 3) ||
!strncmp(root_device_name, "ubi", 3))
return Root_Generic;
return name_to_dev_t(root_device_name);
}
/* /*
* Prepare the namespace - decide what/where to mount, load ramdisks, etc. * Prepare the namespace - decide what/where to mount, load ramdisks, etc.
*/ */
...@@ -624,15 +636,8 @@ void __init prepare_namespace(void) ...@@ -624,15 +636,8 @@ void __init prepare_namespace(void)
md_run_setup(); md_run_setup();
if (saved_root_name[0]) { if (saved_root_name[0])
if (!strncmp(saved_root_name, "mtd", 3) || ROOT_DEV = parse_root_device(saved_root_name);
!strncmp(saved_root_name, "ubi", 3)) {
mount_root_generic(saved_root_name, saved_root_name,
root_mountflags);
goto out;
}
ROOT_DEV = name_to_dev_t(saved_root_name);
}
if (initrd_load(saved_root_name)) if (initrd_load(saved_root_name))
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment