Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 07d63cb

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: Christoph Hellwig <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 73231b5 commit 07d63cb

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

include/linux/root_dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
enum {
1010
Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
1111
Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
12+
Root_Generic = MKDEV(UNNAMED_MAJOR, 253),
1213
Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
1314
};
1415

init/do_mounts.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,10 @@ void __init mount_root(char *root_device_name)
591591
case Root_CIFS:
592592
mount_cifs_root();
593593
break;
594+
case Root_Generic:
595+
mount_root_generic(root_device_name, root_device_name,
596+
root_mountflags);
597+
break;
594598
case 0:
595599
if (root_device_name && root_fs_names &&
596600
mount_nodev_root(root_device_name) == 0)
@@ -602,6 +606,14 @@ void __init mount_root(char *root_device_name)
602606
}
603607
}
604608

609+
static dev_t __init parse_root_device(char *root_device_name)
610+
{
611+
if (!strncmp(root_device_name, "mtd", 3) ||
612+
!strncmp(root_device_name, "ubi", 3))
613+
return Root_Generic;
614+
return name_to_dev_t(root_device_name);
615+
}
616+
605617
/*
606618
* Prepare the namespace - decide what/where to mount, load ramdisks, etc.
607619
*/
@@ -624,15 +636,8 @@ void __init prepare_namespace(void)
624636

625637
md_run_setup();
626638

627-
if (saved_root_name[0]) {
628-
if (!strncmp(saved_root_name, "mtd", 3) ||
629-
!strncmp(saved_root_name, "ubi", 3)) {
630-
mount_root_generic(saved_root_name, saved_root_name,
631-
root_mountflags);
632-
goto out;
633-
}
634-
ROOT_DEV = name_to_dev_t(saved_root_name);
635-
}
639+
if (saved_root_name[0])
640+
ROOT_DEV = parse_root_device(saved_root_name);
636641

637642
if (initrd_load(saved_root_name))
638643
goto out;

0 commit comments

Comments
 (0)