From 40841b2d221273a08abfe20824e7631211ade31d Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Tue, 1 Mar 2011 14:04:00 +0100 Subject: Move system image initialization to core. Change-Id: Ic8da3ccaed9bab7dbb44c0bb341b0dba20b90980 --- vl-android.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'vl-android.c') diff --git a/vl-android.c b/vl-android.c index 04fed59..36289e4 100644 --- a/vl-android.c +++ b/vl-android.c @@ -60,6 +60,7 @@ #include "android/utils/filelock.h" #include "android/utils/path.h" #include "android/utils/stralloc.h" +#include "android/utils/tempfile.h" #include "android/display-core.h" #include "android/utils/timezone.h" #include "android/snapshot.h" @@ -4841,6 +4842,41 @@ int main(int argc, char **argv, char **envp) } #endif // CONFIG_NAND_LIMITS + /* Initialize system partition image */ + { + char tmp[PATH_MAX+32]; + const char* sysImage = android_hw->disk_systemPartition_path; + const char* initImage = android_hw->disk_systemPartition_initPath; + uint64_t sysBytes = android_hw->disk_systemPartition_size; + + if (sysBytes == 0) { + PANIC("Invalid system partition size: %" PRUd64, sysBytes); + } + + snprintf(tmp,sizeof(tmp),"system,size=0x%" PRUx64, sysBytes); + + if (sysImage && *sysImage) { + if (filelock_create(sysImage) == NULL) { + fprintf(stderr,"WARNING: System image already in use, changes will not persist!\n"); + /* If there is no file= parameters, nand_add_dev will create + * a temporary file to back the partition image. */ + } else { + pstrcat(tmp,sizeof(tmp),",file="); + pstrcat(tmp,sizeof(tmp),sysImage); + } + } + if (initImage && *initImage) { + if (!path_exists(initImage)) { + PANIC("Invalid initial system image path: %s", initImage); + } + pstrcat(tmp,sizeof(tmp),",initfile="); + pstrcat(tmp,sizeof(tmp),initImage); + } else { + PANIC("Missing initial system image path!"); + } + nand_add_dev(tmp); + } + /* Init SD-Card stuff. For Android, it is always hda */ /* If the -hda option was used, ignore the Android-provided one */ if (hda_opts == NULL) { -- cgit v1.1