.. | .. |
---|
8 | 8 | #include <linux/sched.h> |
---|
9 | 9 | #include <linux/freezer.h> |
---|
10 | 10 | #include <linux/kmod.h> |
---|
| 11 | +#include <uapi/linux/mount.h> |
---|
11 | 12 | |
---|
12 | 13 | #include "do_mounts.h" |
---|
13 | 14 | |
---|
.. | .. |
---|
15 | 16 | int initrd_below_start_ok; |
---|
16 | 17 | unsigned int real_root_dev; /* do_proc_dointvec cannot handle kdev_t */ |
---|
17 | 18 | static int __initdata mount_initrd = 1; |
---|
| 19 | + |
---|
| 20 | +phys_addr_t phys_initrd_start __initdata; |
---|
| 21 | +unsigned long phys_initrd_size __initdata; |
---|
18 | 22 | |
---|
19 | 23 | static int __init no_initrd(char *str) |
---|
20 | 24 | { |
---|
.. | .. |
---|
24 | 28 | |
---|
25 | 29 | __setup("noinitrd", no_initrd); |
---|
26 | 30 | |
---|
27 | | -static int init_linuxrc(struct subprocess_info *info, struct cred *new) |
---|
| 31 | +static int __init early_initrdmem(char *p) |
---|
| 32 | +{ |
---|
| 33 | + phys_addr_t start; |
---|
| 34 | + unsigned long size; |
---|
| 35 | + char *endp; |
---|
| 36 | + |
---|
| 37 | + start = memparse(p, &endp); |
---|
| 38 | + if (*endp == ',') { |
---|
| 39 | + size = memparse(endp + 1, NULL); |
---|
| 40 | + |
---|
| 41 | + phys_initrd_start = start; |
---|
| 42 | + phys_initrd_size = size; |
---|
| 43 | + } |
---|
| 44 | + return 0; |
---|
| 45 | +} |
---|
| 46 | +early_param("initrdmem", early_initrdmem); |
---|
| 47 | + |
---|
| 48 | +static int __init early_initrd(char *p) |
---|
| 49 | +{ |
---|
| 50 | + return early_initrdmem(p); |
---|
| 51 | +} |
---|
| 52 | +early_param("initrd", early_initrd); |
---|
| 53 | + |
---|
| 54 | +static int __init init_linuxrc(struct subprocess_info *info, struct cred *new) |
---|
28 | 55 | { |
---|
29 | 56 | ksys_unshare(CLONE_FS | CLONE_FILES); |
---|
30 | | - /* stdin/stdout/stderr for /linuxrc */ |
---|
31 | | - ksys_open("/dev/console", O_RDWR, 0); |
---|
32 | | - ksys_dup(0); |
---|
33 | | - ksys_dup(0); |
---|
| 57 | + console_on_rootfs(); |
---|
34 | 58 | /* move initrd over / and chdir/chroot in initrd root */ |
---|
35 | | - ksys_chdir("/root"); |
---|
36 | | - ksys_mount(".", "/", NULL, MS_MOVE, NULL); |
---|
37 | | - ksys_chroot("."); |
---|
| 59 | + init_chdir("/root"); |
---|
| 60 | + init_mount(".", "/", NULL, MS_MOVE, NULL); |
---|
| 61 | + init_chroot("."); |
---|
38 | 62 | ksys_setsid(); |
---|
39 | 63 | return 0; |
---|
40 | 64 | } |
---|
.. | .. |
---|
46 | 70 | extern char *envp_init[]; |
---|
47 | 71 | int error; |
---|
48 | 72 | |
---|
| 73 | + pr_warn("using deprecated initrd support, will be removed in 2021.\n"); |
---|
| 74 | + |
---|
49 | 75 | real_root_dev = new_encode_dev(ROOT_DEV); |
---|
50 | 76 | create_dev("/dev/root.old", Root_RAM0); |
---|
51 | 77 | /* mount initrd on rootfs' /root */ |
---|
52 | 78 | mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY); |
---|
53 | | - ksys_mkdir("/old", 0700); |
---|
54 | | - ksys_chdir("/old"); |
---|
55 | | - |
---|
56 | | - /* try loading default modules from initrd */ |
---|
57 | | - load_default_modules(); |
---|
| 79 | + init_mkdir("/old", 0700); |
---|
| 80 | + init_chdir("/old"); |
---|
58 | 81 | |
---|
59 | 82 | /* |
---|
60 | 83 | * In case that a resume from disk is carried out by linuxrc or one of |
---|
.. | .. |
---|
71 | 94 | current->flags &= ~PF_FREEZER_SKIP; |
---|
72 | 95 | |
---|
73 | 96 | /* move initrd to rootfs' /old */ |
---|
74 | | - ksys_mount("..", ".", NULL, MS_MOVE, NULL); |
---|
| 97 | + init_mount("..", ".", NULL, MS_MOVE, NULL); |
---|
75 | 98 | /* switch root and cwd back to / of rootfs */ |
---|
76 | | - ksys_chroot(".."); |
---|
| 99 | + init_chroot(".."); |
---|
77 | 100 | |
---|
78 | 101 | if (new_decode_dev(real_root_dev) == Root_RAM0) { |
---|
79 | | - ksys_chdir("/old"); |
---|
| 102 | + init_chdir("/old"); |
---|
80 | 103 | return; |
---|
81 | 104 | } |
---|
82 | 105 | |
---|
83 | | - ksys_chdir("/"); |
---|
| 106 | + init_chdir("/"); |
---|
84 | 107 | ROOT_DEV = new_decode_dev(real_root_dev); |
---|
85 | 108 | mount_root(); |
---|
86 | 109 | |
---|
87 | 110 | printk(KERN_NOTICE "Trying to move old root to /initrd ... "); |
---|
88 | | - error = ksys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL); |
---|
| 111 | + error = init_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL); |
---|
89 | 112 | if (!error) |
---|
90 | 113 | printk("okay\n"); |
---|
91 | 114 | else { |
---|
92 | | - int fd = ksys_open("/dev/root.old", O_RDWR, 0); |
---|
93 | 115 | if (error == -ENOENT) |
---|
94 | 116 | printk("/initrd does not exist. Ignored.\n"); |
---|
95 | 117 | else |
---|
96 | 118 | printk("failed\n"); |
---|
97 | 119 | printk(KERN_NOTICE "Unmounting old root\n"); |
---|
98 | | - ksys_umount("/old", MNT_DETACH); |
---|
99 | | - printk(KERN_NOTICE "Trying to free ramdisk memory ... "); |
---|
100 | | - if (fd < 0) { |
---|
101 | | - error = fd; |
---|
102 | | - } else { |
---|
103 | | - error = ksys_ioctl(fd, BLKFLSBUF, 0); |
---|
104 | | - ksys_close(fd); |
---|
105 | | - } |
---|
106 | | - printk(!error ? "okay\n" : "failed\n"); |
---|
| 120 | + init_umount("/old", MNT_DETACH); |
---|
107 | 121 | } |
---|
108 | 122 | } |
---|
109 | 123 | |
---|
.. | .. |
---|
118 | 132 | * mounted in the normal path. |
---|
119 | 133 | */ |
---|
120 | 134 | if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { |
---|
121 | | - ksys_unlink("/initrd.image"); |
---|
| 135 | + init_unlink("/initrd.image"); |
---|
122 | 136 | handle_initrd(); |
---|
123 | 137 | return true; |
---|
124 | 138 | } |
---|
125 | 139 | } |
---|
126 | | - ksys_unlink("/initrd.image"); |
---|
| 140 | + init_unlink("/initrd.image"); |
---|
127 | 141 | return false; |
---|
128 | 142 | } |
---|