欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 汽车 > 新车 > x210项目重新回顾之十八bootargs的root设置的解析

x210项目重新回顾之十八bootargs的root设置的解析

2024/10/26 4:30:49 来源:https://blog.csdn.net/conjimmy/article/details/141907043  浏览:    关键词:x210项目重新回顾之十八bootargs的root设置的解析

这个问题困扰我很久,root=/dev/mmcblk0p2如何被解析的,

疑问:

1)还没加载外部(mmc0的第二分区上,也就mmcblk0p2)跟文件系统时候,"/"目录和"/dev",如何提前存在:

答案:原来提前加载了虚拟的rootfs(rootfs在linux内核这里是专有名字),这在vfs_cache_init()里面实现,具体参考:

文件系统(五)—VFS初始化_rootfstype=tmpfs-CSDN博客

2)加载外部根文件系统时候,root=/dev/mmcblk0p2如何被解析的,

答案,分析启动打印,发现:

 mmc0: SDHCI controller on samsung-hsmmc [s3c-sdhci.0] using ADMA
s3c-sdhci s3c-sdhci.1: clock source 0: hsmmc (133400000 Hz)
s3c-sdhci s3c-sdhci.1: clock source 1: hsmmc (133400000 Hz)
s3c-sdhci s3c-sdhci.1: clock source 2: sclk_mmc (47642857 Hz)

 mmc0: new high speed MMC card at address 0001
mmcblk0: mmc0:0001 004GE0 3.68 GiB
  mmcblk0: p1 p2 p3 p4

 List of all partitions:
 b300         3866624 mmcblk0 driver: mmcblk
   b301          264495 mmcblk0p1
   b302          124690 mmcblk0p2
  b303          105798 mmcblk0p3
  b304         3347751 mmcblk0p4
 b308        15558144 mmcblk1 driver: mmcblk
  b309          102400 mmcblk1p1
  b30a          102400 mmcblk1p2
  b30b          102400 mmcblk1p3
  b30c        15230464 mmcblk1p4

VFS: Mounted root (ext3 filesystem) on device 179:2.

在内核源码上查询:

jimmy@ubuntu:~/news5pv210/Linux-Kernel-2.6.35/kernel$ grep "List of all partitions" -nR *
init/do_mounts.c:277:   printk("List of all partitions:\n");

打开init/do_mounts.c: 发现上头有:

 *      Convert a name into device number.  We accept the following variants:

 *      1) device number in hexadecimal represents itself

 *      2) /dev/nfs represents Root_NFS (0xff)

 *      3) /dev/<disk_name> represents the device number of disk

 *      4) /dev/<disk_name><decimal> represents the device number

 *         of partition - device number of disk plus the partition number

 *      5) /dev/<disk_name>p<decimal> - same as the above, that form is

 *         used when disk name of partitioned disk ends on a digit.

 *      If name doesn't have fall into the categories above, we return (0,0).

 *      block_class is used to check if something is a disk name. If the disk

 *      name contains slashes, the device name has them replaced with

 *      bangs.

顿时豁然开朗:

这可以在系统启动后得到证实:

 ls /dev/root
/dev/root
/ # ls /dev/root  -alt
lrwxrwxrwx    1 0        0                9 Jan  1 12:22 /dev/root -> mmcblk0p2
/ # ls /dev/mmc* -alt
brw-r--r--    1 0        0         179,  16 Jan  1 17:00 /dev/mmcblk2
brw-rw----    1 0        0         179,   0 Jan  1 12:22 /dev/mmcblk0
brw-rw----    1 0        0         179,   1 Jan  1 12:22 /dev/mmcblk0p1
brw-rw----    1 0        0         179,   2 Jan  1 12:22 /dev/mmcblk0p2
brw-rw----    1 0        0         179,   3 Jan  1 12:22 /dev/mmcblk0p3
brw-rw----    1 0        0         179,   4 Jan  1 12:22 /dev/mmcblk0p4
brw-rw----    1 0        0         179,   8 Jan  1 12:22 /dev/mmcblk1
brw-rw----    1 0        0         179,   9 Jan  1 12:22 /dev/mmcblk1p1
brw-rw----    1 0        0         179,  10 Jan  1 12:22 /dev/mmcblk1p2
brw-rw----    1 0        0         179,  11 Jan  1 12:22 /dev/mmcblk1p3
brw-rw----    1 0        0         179,  12 Jan  1 12:22 /dev/mmcblk1p4
 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com