init.rc中command案例使用


android在线升级或双系统,即一个系统出问题恢复到另一个系统等等,我们需要把system挂载到不同的磁盘下面


init.rc有下面一些信息

on fs
# mount ext4 partitions
    mount ext4 /dev/block/mmcblk0p2 /system ro
  
on fs-b
# mount ext4 partitions
    mount ext4 /dev/block/mmcblk0p9 /system ro

在init.c中有如下的代码

 if(!strncmp(boot_type, "1", 1)) {
            action_for_each_trigger("fs-b", action_add_queue_tail);
        } else {
            action_for_each_trigger("fs", action_add_queue_tail);
        }

这里我们需要知道boot_type的值,这个值是怎么来的呢?

 strlcpy(boot_type, value, sizeof(boot_type));

而这条语句是在下面方法中

static void import_kernel_nv(char *name, int in_qemu)
{
    char *value = strchr(name, '=');

    if (value == 0) {
	if (!strcmp(name, "calibration"))
	    calibration = 1;
	return;
    }
    *value++ = 0;
    if (*name == 0) return;

    if (!in_qemu)
    {
        /* on a real device, white-list the kernel options */
        if (!strcmp(name,"qemu")) {
            strlcpy(qemu, value, sizeof(qemu));
        } else if (!strcmp(name,"androidboot.console")) {
            strlcpy(console, value, sizeof(console));
        } else if (!strcmp(name,"androidboot.mode")) {
            strlcpy(bootmode, value, sizeof(bootmode));
        } else if (!strcmp(name,"androidboot.serialno")) {
            strlcpy(serialno, value, sizeof(serialno));
        } else if (!strcmp(name,"androidboot.baseband")) {
            strlcpy(baseband, value, sizeof(baseband));
        } else if (!strcmp(name,"androidboot.carrier")) {
            strlcpy(carrier, value, sizeof(carrier));
        } else if (!strcmp(name,"androidboot.bootloader")) {
            strlcpy(bootloader, value, sizeof(bootloader));
        } else if (!strcmp(name,"androidboot.hardware")) {
            strlcpy(hardware, value, sizeof(hardware));
        } else if (!strcmp(name,"androidboot.modelno")) {
            strlcpy(modelno, value, sizeof(modelno));
        } else if (!strcmp(name,"boot_type")) {
            strlcpy(boot_type, value, sizeof(boot_type));
        }
    } else {
        /* in the emulator, export any kernel option with the
         * ro.kernel. prefix */
        char  buff[32];
        int   len = snprintf( buff, sizeof(buff), "ro.kernel.%s", name );
        if (len < (int)sizeof(buff)) {
            property_set( buff, value );
        }
    }
}

上面的方法import_kernel_nv是在哪执行的呢?

    /* pull the kernel commandline and ramdisk properties file in */
    import_kernel_cmdline(0, import_kernel_nv);

从上面来看是用import_kernel_nv函数来指定解析commandline,而boot_type的值就是在commandline中




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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值