VFS Travelling (2)

In this section, i would start the VFS travelling from rootfs. I'm showing out what happens to VFS when kernel starts. 

The main scenario is shown below.

 

Fig 2-1

 

 

Let's get a further step to break it down.

1.       In start_kernel context, vfs_caches_init() will call mnt_init(), and the following figure shows the hierarchy of mnt_init.



 

 

Fig 2-2

 

 

After register_filesystem(), the structure of file_systems is shown below:

Fig 2-3

 

 

And then inside do_kern_mount()

1)       get_fs_type() to get a pointer points to the root file system type, which had already been shown above;

2)       vfs_kern_mount is called. Firstly, it calls alloc_vfsmnt() to allocate a mount node and then initialize it;

3)       Call type->get_sb which is actually get_sb_nodev(). It allocates a super block and initializes it, and then links s_instances to fs_supers list of root file system type node. Please be noted that when we called do_kern_mount("rootfs", 0, "rootfs", NULL) previously, the last input parameter is NULL, which means when we called mount_nodev(fs_type, flags, data, fill_super) inside get_sb_nodev(), the fill_super() function was NULL.


So after that, the structures inside RAM are like below:

Fig 2-4

 

 

2.       In kernel_init context, let’s check Makefile firstly.

 

Let's analyze the source code by the following two figures.


 

Fig 2-5

 

 

Fig 2-6

 

Take jffs2 rootfs for example. If we use u-boot to boot-up the kernel, few available boot arguments are shown below:

  • cramfs: setenv bootargs root=/dev/mtdblock2 init=/linuxrc console=ttySAC0,115200
  • ramdisk: setenv bootargs initrd=0x31000000,0x200000 root=/dev/ram0 rw init=/linuxrc console=ttySAC0,115200
  • jffs2: setenv bootargs root=/dev/mtdblock2 rootfstype=jffs2 rw console=ttySAC0,115200 init=/linuxrc

After above operations, the structure organization is updated as below:


 

Fig 2-7

 

(To be continue)

 

References:

 

[1] http://www.ibm.com/developerworks/cn/linux/l-vfs/

 

 


 

 


 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值