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中