加入收藏 | 设为首页 | 会员中心 | 我要投稿 网站开发网_安阳站长网 (https://www.0372zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长百科 > 正文

深度解析Linux根文件系统的挂载过程

发布时间:2020-12-30 22:41:23 所属栏目:站长百科 来源:网络整理
导读:副标题#e# 《深度解析Linux根文件系统的挂载过程》要点: 本文介绍了深度解析Linux根文件系统的挂载过程,希望对您有用。如果有疑问,可以联系我们。 在前面的文章中介绍《Linux操作系统启动过程》,而Linux系统的根文件系统(root file system)的挂载过程则

if (sys_access((const char __user *) ramdisk_execute_command,and
* we’re essentially up and running. Get rid of the
* initmem segments and start the user-mode stuff..
*/
init_post();
return 0;
}[/code]

ramdisk_execute_command:在kernel解析引导参数的时候使用.如果用户指定了init文件路径,即使用了“init=”,就会将这个参数值存放到这里.
如果没有指定init文件路径.默认为/init
对应于前面一段的分析,我们知道,对于initramdisk和cpio-initrd的情况,都会将虚拟根文件系统释放到根目录.如果这些虚拟文件系统里有/init这个文件.就会转入到init_post().
Init_post()代码如下:

[code lang=”c”]static int noinline init_post(void)
{
free_initmem();
unlock_kernel();
mark_rodata_ro();
system_state = SYSTEM_RUNNING;
numa_default_policy();

if (sys_open((const char __user *) "/dev/console",O_RDWR,0)
(void) sys_dup(0);
(void) sys_dup(0);

if (ramdisk_execute_command) {
run_init_process(ramdisk_execute_command);
printk(KERN_WARNING "Failed to execute %sn",
ramdisk_execute_command);
}

/*
* We try each of these until one succeeds.
*
* The Bourne shell can be used instead of init if we are
* trying to recover a really broken machine.
*/
if (execute_command) {
run_init_process(execute_command);
printk(KERN_WARNING "Failed to execute %s. Attempting "
"defaults…n",execute_command);
}
run_init_process("/sbin/init");
run_init_process("/etc/init");
run_init_process("/bin/init");
run_init_process("/bin/sh");

panic("No init found. Try passing init= option to kernel.");
}[/code]

(编辑:网站开发网_安阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!