aboutsummaryrefslogtreecommitdiffstats
path: root/vl-android.c
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2011-03-15 23:08:50 +0100
committerDavid 'Digit' Turner <digit@android.com>2011-03-15 23:08:50 +0100
commite8ab08c1ee27349cb81cd5e8849a01a85da16775 (patch)
tree820c86645d685717e989648dac8cbbb41a05976c /vl-android.c
parent356e18be0ec6c7d92d116f75130e2cb8db4b114a (diff)
downloadexternal_qemu-e8ab08c1ee27349cb81cd5e8849a01a85da16775.zip
external_qemu-e8ab08c1ee27349cb81cd5e8849a01a85da16775.tar.gz
external_qemu-e8ab08c1ee27349cb81cd5e8849a01a85da16775.tar.bz2
Fix a crash that happened when the content directory didn't have a cache.img file.
This only happened for fresh newly-created AVDs. Existing ones used for testing the emulator already had a cache.img and booted properly. Change-Id: I87901ea5fb1dc6aa7d2bb3dd191de58d972c386f
Diffstat (limited to 'vl-android.c')
-rw-r--r--vl-android.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/vl-android.c b/vl-android.c
index ce9440e..e140cb2 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -5045,7 +5045,9 @@ int main(int argc, char **argv, char **envp)
} else {
/* Create the file if needed */
if (!path_exists(dataImage)) {
- path_empty_file(dataImage);
+ if (path_empty_file(dataImage) < 0) {
+ PANIC("Could not create data image file %s: %s", dataImage, strerror(errno));
+ }
}
pstrcat(tmp, sizeof(tmp), ",file=");
pstrcat(tmp, sizeof(tmp), dataImage);
@@ -5225,17 +5227,25 @@ int main(int argc, char **argv, char **envp)
if (android_hw->disk_cachePartition != 0) {
char tmp[PATH_MAX+32];
const char* partPath = android_hw->disk_cachePartition_path;
- uint32_t partSize = android_hw->disk_cachePartition_size;
+ uint64_t partSize = android_hw->disk_cachePartition_size;
- if (!partPath || !*partPath || !strcmp(partPath, "<temp>"))
- {
- /* Use temporary cache partition */
- snprintf(tmp, sizeof(tmp), "cache,size=0x%x", partSize);
- }
- else
- {
- /* Use specific cache partition */
- snprintf(tmp, sizeof(tmp), "cache,size=0x%x,file=%s", partSize, partPath);
+ snprintf(tmp,sizeof(tmp),"cache,size=0x%" PRUx64, partSize);
+
+ if (partPath && *partPath && strcmp(partPath, "<temp>") != 0) {
+ if (filelock_create(partPath) == NULL) {
+ fprintf(stderr, "WARNING: Cache partition already in use. Changes will not persist!\n");
+ /* Note: if there is no file= parameters, nand_add_dev() will
+ * create a temporary file to back the partition image. */
+ } else {
+ /* Create the file if needed */
+ if (!path_exists(partPath)) {
+ if (path_empty_file(partPath) < 0) {
+ PANIC("Could not create cache image file %s: %s", partPath, strerror(errno));
+ }
+ }
+ pstrcat(tmp, sizeof(tmp), ",file=");
+ pstrcat(tmp, sizeof(tmp), partPath);
+ }
}
nand_add_dev(tmp);
}