From 26d415322b75784f123d39f36616b8ebd1fbb359 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Tue, 1 Mar 2011 15:03:07 +0100 Subject: Prevent hardware-qemu.ini overwrites. When launching two instances of the same AVD, we need to ensure that we don't end-up overwriting the hardware-qemu.ini in the content directory. Note that this case is supported at the moment. Both the system and data partition will be backed by a temporary file when this is detected. Change-Id: I2c5d9195edc4c5be3b889c8da38cb1c7cae3662a --- android/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'android/main.c') diff --git a/android/main.c b/android/main.c index 198212f..4315c4e 100644 --- a/android/main.c +++ b/android/main.c @@ -38,6 +38,7 @@ #include "android/user-config.h" #include "android/utils/bufprint.h" +#include "android/utils/filelock.h" #include "android/utils/path.h" #include "android/utils/tempfile.h" @@ -837,17 +838,26 @@ int main(int argc, char **argv) } args[n] = 0; - /* Generate a temporary hardware.ini for this AVD. The real hardware + /* Generate a hardware-qemu.ini for this AVD. The real hardware * configuration is ususally stored in several files, e.g. the AVD's * config.ini plus the skin-specific hardware.ini. * - * The new temp file will group all definitions and will be used to + * The new file will group all definitions and will be used to * launch the core with the -android-hw option. */ { const char* coreHwIniPath = avdInfo_getCoreHwIniPath(avd); IniFile* hwIni = iniFile_newFromMemory("", NULL); androidHwConfig_write(hw, hwIni); + + if (filelock_create(coreHwIniPath) == NULL) { + /* The AVD is already in use, we still support this as an + * experimental feature. Use a temporary hardware-qemu.ini + * file though to avoid overwriting the existing one. */ + TempFile* tempIni = tempfile_create(); + coreHwIniPath = tempfile_path(tempIni); + } + if (iniFile_saveToFile(hwIni, coreHwIniPath) < 0) { derror("Could not write hardware.ini to %s: %s", coreHwIniPath, strerror(errno)); exit(2); -- cgit v1.1