Move the SD Card initialization to the core.
Change-Id: I2c8fa2a7df3d79ed4222296a93b787994a8ee11d
diff --git a/vl-android.c b/vl-android.c
index 379741b..d07b6c0 100644
--- a/vl-android.c
+++ b/vl-android.c
@@ -57,6 +57,8 @@
#include "android/globals.h"
#include "android/utils/bufprint.h"
#include "android/utils/debug.h"
+#include "android/utils/filelock.h"
+#include "android/utils/path.h"
#include "android/utils/stralloc.h"
#include "android/display-core.h"
#include "android/utils/timezone.h"
@@ -4835,6 +4837,22 @@
}
#endif // CONFIG_NAND_LIMITS
+ /* 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) {
+ const char* sdPath = android_hw->hw_sdCard_path;
+ if (sdPath && *sdPath) {
+ if (!path_exists(sdPath)) {
+ fprintf(stderr, "WARNING: SD Card image is missing: %s\n", sdPath);
+ } else if (filelock_create(sdPath) == NULL) {
+ fprintf(stderr, "WARNING: SD Card image already in use: %s\n", sdPath);
+ } else {
+ /* Successful locking */
+ hda_opts = drive_add(sdPath, HD_ALIAS, 0);
+ }
+ }
+ }
+
/* Set the VM's max heap size, passed as a boot property */
if (android_hw->vm_heapSize > 0) {
char tmp[64];