Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: pass root_device_name explicitly

Instead of declaring root_device_name as a global variable pass it as an
argument to the functions using it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20230531125535.676098-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
c8643c72 a6a41d39

+29 -25
+16 -13
init/do_mounts.c
··· 28 28 #include "do_mounts.h" 29 29 30 30 int root_mountflags = MS_RDONLY | MS_SILENT; 31 - static char * __initdata root_device_name; 32 31 static char __initdata saved_root_name[64]; 33 32 static int root_wait; 34 33 ··· 390 391 return ret; 391 392 } 392 393 393 - void __init mount_root_generic(char *name, int flags) 394 + void __init mount_root_generic(char *name, char *pretty_name, int flags) 394 395 { 395 396 struct page *page = alloc_page(GFP_KERNEL); 396 397 char *fs_names = page_address(page); ··· 424 425 * and give them a list of the available devices 425 426 */ 426 427 printk("VFS: Cannot open root device \"%s\" or %s: error %d\n", 427 - root_device_name, b, err); 428 + pretty_name, b, err); 428 429 printk("Please append a correct \"root=\" boot option; here are the available partitions:\n"); 429 430 430 431 printk_all_partitions(); ··· 540 541 return ret; 541 542 } 542 543 543 - static int __init mount_nodev_root(void) 544 + static int __init mount_nodev_root(char *root_device_name) 544 545 { 545 546 char *fs_names, *fstype; 546 547 int err = -EINVAL; ··· 568 569 } 569 570 570 571 #ifdef CONFIG_BLOCK 571 - static void __init mount_block_root(void) 572 + static void __init mount_block_root(char *root_device_name) 572 573 { 573 574 int err = create_dev("/dev/root", ROOT_DEV); 574 575 575 576 if (err < 0) 576 577 pr_emerg("Failed to create /dev/root: %d\n", err); 577 - mount_root_generic("/dev/root", root_mountflags); 578 + mount_root_generic("/dev/root", root_device_name, root_mountflags); 578 579 } 579 580 #else 580 - static inline void mount_block_root(void) 581 + static inline void mount_block_root(char *root_device_name) 581 582 { 582 583 } 583 584 #endif /* CONFIG_BLOCK */ 584 585 585 - void __init mount_root(void) 586 + void __init mount_root(char *root_device_name) 586 587 { 587 588 switch (ROOT_DEV) { 588 589 case Root_NFS: ··· 592 593 mount_cifs_root(); 593 594 break; 594 595 case 0: 595 - if (root_device_name && root_fs_names && mount_nodev_root() == 0) 596 + if (root_device_name && root_fs_names && 597 + mount_nodev_root(root_device_name) == 0) 596 598 break; 597 599 fallthrough; 598 600 default: 599 - mount_block_root(); 601 + mount_block_root(root_device_name); 600 602 break; 601 603 } 602 604 } ··· 607 607 */ 608 608 void __init prepare_namespace(void) 609 609 { 610 + char *root_device_name; 611 + 610 612 if (root_delay) { 611 613 printk(KERN_INFO "Waiting %d sec before mounting root device...\n", 612 614 root_delay); ··· 630 628 root_device_name = saved_root_name; 631 629 if (!strncmp(root_device_name, "mtd", 3) || 632 630 !strncmp(root_device_name, "ubi", 3)) { 633 - mount_root_generic(root_device_name, root_mountflags); 631 + mount_root_generic(root_device_name, root_device_name, 632 + root_mountflags); 634 633 goto out; 635 634 } 636 635 ROOT_DEV = name_to_dev_t(root_device_name); ··· 639 636 root_device_name += 5; 640 637 } 641 638 642 - if (initrd_load()) 639 + if (initrd_load(root_device_name)) 643 640 goto out; 644 641 645 642 /* wait for any asynchronous scanning to complete */ ··· 652 649 async_synchronize_full(); 653 650 } 654 651 655 - mount_root(); 652 + mount_root(root_device_name); 656 653 out: 657 654 devtmpfs_mount(); 658 655 init_mount(".", "/", NULL, MS_MOVE, NULL);
+7 -7
init/do_mounts.h
··· 10 10 #include <linux/root_dev.h> 11 11 #include <linux/init_syscalls.h> 12 12 13 - void mount_root_generic(char *name, int flags); 14 - void mount_root(void); 13 + void mount_root_generic(char *name, char *pretty_name, int flags); 14 + void mount_root(char *root_device_name); 15 15 extern int root_mountflags; 16 16 17 17 static inline __init int create_dev(char *name, dev_t dev) ··· 33 33 #endif 34 34 35 35 #ifdef CONFIG_BLK_DEV_INITRD 36 - 37 - bool __init initrd_load(void); 38 - 36 + bool __init initrd_load(char *root_device_name); 39 37 #else 40 - 41 - static inline bool initrd_load(void) { return false; } 38 + static inline bool initrd_load(char *root_device_name) 39 + { 40 + return false; 41 + } 42 42 43 43 #endif
+6 -5
init/do_mounts_initrd.c
··· 83 83 return 0; 84 84 } 85 85 86 - static void __init handle_initrd(void) 86 + static void __init handle_initrd(char *root_device_name) 87 87 { 88 88 struct subprocess_info *info; 89 89 static char *argv[] = { "linuxrc", NULL, }; ··· 95 95 real_root_dev = new_encode_dev(ROOT_DEV); 96 96 create_dev("/dev/root.old", Root_RAM0); 97 97 /* mount initrd on rootfs' /root */ 98 - mount_root_generic("/dev/root.old", root_mountflags & ~MS_RDONLY); 98 + mount_root_generic("/dev/root.old", root_device_name, 99 + root_mountflags & ~MS_RDONLY); 99 100 init_mkdir("/old", 0700); 100 101 init_chdir("/old"); 101 102 ··· 118 117 119 118 init_chdir("/"); 120 119 ROOT_DEV = new_decode_dev(real_root_dev); 121 - mount_root(); 120 + mount_root(root_device_name); 122 121 123 122 printk(KERN_NOTICE "Trying to move old root to /initrd ... "); 124 123 error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL); ··· 134 133 } 135 134 } 136 135 137 - bool __init initrd_load(void) 136 + bool __init initrd_load(char *root_device_name) 138 137 { 139 138 if (mount_initrd) { 140 139 create_dev("/dev/ram", Root_RAM0); ··· 146 145 */ 147 146 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { 148 147 init_unlink("/initrd.image"); 149 - handle_initrd(); 148 + handle_initrd(root_device_name); 150 149 return true; 151 150 } 152 151 }