diff options
-rw-r--r-- | hw/goldfish_nand.c | 5 | ||||
-rw-r--r-- | vl-android.c | 32 |
2 files changed, 24 insertions, 13 deletions
diff --git a/hw/goldfish_nand.c b/hw/goldfish_nand.c index 8d9b5db..eb0c355 100644 --- a/hw/goldfish_nand.c +++ b/hw/goldfish_nand.c @@ -688,10 +688,11 @@ void nand_add_dev(const char *arg) if(value != NULL) goto bad_arg_and_value; devname_len = arg_len; - devname = malloc(arg_len); + devname = malloc(arg_len+1); if(devname == NULL) goto out_of_memory; memcpy(devname, arg, arg_len); + devname[arg_len] = 0; } else if(value == NULL) { if(arg_match("readonly", arg, arg_len)) { @@ -765,7 +766,7 @@ void nand_add_dev(const char *arg) if(rwfilename) { rwfd = open(rwfilename, O_BINARY | (read_only ? O_RDONLY : O_RDWR)); - if(rwfd < 0 && read_only) { + if(rwfd < 0) { XLOG("could not open file %s, %s\n", rwfilename, strerror(errno)); exit(1); } 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); } |