如果有点问题要kernel reboot才能复制到,但又不用跑到user space,可以在kernel_init 中加
kernel_restart(NULL);
就如下面的952和953 之间,955行就要跑user space的init了,因此这里是最适合reboot的地方,这时整个kernel
都已经初始化了.
static int __ref kernel_init(void *unused)
939{
940 int ret;
941
942 kernel_init_freeable();
943 /* need to finish all async __init code before freeing the memory */
944 async_synchronize_full();
945 free_initmem();
946 mark_readonly();
947 system_state = SYSTEM_RUNNING;
948 numa_default_policy();
949
950 flush_delayed_fput();
951
952 rcu_end_inkernel_boot();
kernel_restart(NULL);
953
954 if (ramdisk_execute_command) {
955 ret = run_init_process(ramdisk_execute_command);
956 if (!ret)
957 return 0;
958 pr_err("Failed to execute %s (error %d)\n",
959 ramdisk_execute_command, ret);
960 }
kernel_restart(NULL);
就如下面的952和953 之间,955行就要跑user space的init了,因此这里是最适合reboot的地方,这时整个kernel
都已经初始化了.
static int __ref kernel_init(void *unused)
939{
940 int ret;
941
942 kernel_init_freeable();
943 /* need to finish all async __init code before freeing the memory */
944 async_synchronize_full();
945 free_initmem();
946 mark_readonly();
947 system_state = SYSTEM_RUNNING;
948 numa_default_policy();
949
950 flush_delayed_fput();
951
952 rcu_end_inkernel_boot();
kernel_restart(NULL);
953
954 if (ramdisk_execute_command) {
955 ret = run_init_process(ramdisk_execute_command);
956 if (!ret)
957 return 0;
958 pr_err("Failed to execute %s (error %d)\n",
959 ramdisk_execute_command, ret);
960 }