am 2c3c5c15: Merge "mount sdcard only on demand; fix sideload installs" into gingerbread
Merge commit '2c3c5c15d15faf1c9fa074851c57d0afa2a40d28' into gingerbread-plus-aosp * commit '2c3c5c15d15faf1c9fa074851c57d0afa2a40d28': mount sdcard only on demand; fix sideload installs
This commit is contained in:
+6
-3
@@ -456,6 +456,8 @@ static int compare_string(const void* a, const void* b) {
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
sdcard_directory(const char* path) {
|
sdcard_directory(const char* path) {
|
||||||
|
ensure_path_mounted(SDCARD_ROOT);
|
||||||
|
|
||||||
const char* MENU_HEADERS[] = { "Choose a package to install:",
|
const char* MENU_HEADERS[] = { "Choose a package to install:",
|
||||||
path,
|
path,
|
||||||
"",
|
"",
|
||||||
@@ -465,6 +467,7 @@ sdcard_directory(const char* path) {
|
|||||||
d = opendir(path);
|
d = opendir(path);
|
||||||
if (d == NULL) {
|
if (d == NULL) {
|
||||||
LOGE("error opening %s: %s\n", path, strerror(errno));
|
LOGE("error opening %s: %s\n", path, strerror(errno));
|
||||||
|
ensure_path_unmounted(SDCARD_ROOT);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -546,11 +549,13 @@ sdcard_directory(const char* path) {
|
|||||||
// the status to the caller.
|
// the status to the caller.
|
||||||
char new_path[PATH_MAX];
|
char new_path[PATH_MAX];
|
||||||
strlcpy(new_path, path, PATH_MAX);
|
strlcpy(new_path, path, PATH_MAX);
|
||||||
|
strlcat(new_path, "/", PATH_MAX);
|
||||||
strlcat(new_path, item, PATH_MAX);
|
strlcat(new_path, item, PATH_MAX);
|
||||||
|
|
||||||
ui_print("\n-- Install %s ...\n", path);
|
ui_print("\n-- Install %s ...\n", path);
|
||||||
set_sdcard_update_bootloader_message();
|
set_sdcard_update_bootloader_message();
|
||||||
char* copy = copy_sideloaded_package(new_path);
|
char* copy = copy_sideloaded_package(new_path);
|
||||||
|
ensure_path_unmounted(SDCARD_ROOT);
|
||||||
if (copy) {
|
if (copy) {
|
||||||
result = install_package(copy);
|
result = install_package(copy);
|
||||||
free(copy);
|
free(copy);
|
||||||
@@ -566,6 +571,7 @@ sdcard_directory(const char* path) {
|
|||||||
free(zips);
|
free(zips);
|
||||||
free(headers);
|
free(headers);
|
||||||
|
|
||||||
|
ensure_path_unmounted(SDCARD_ROOT);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,9 +771,6 @@ main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR);
|
if (status != INSTALL_SUCCESS) ui_set_background(BACKGROUND_ICON_ERROR);
|
||||||
if (status != INSTALL_SUCCESS || ui_text_visible()) {
|
if (status != INSTALL_SUCCESS || ui_text_visible()) {
|
||||||
// Mount the sdcard when the menu is enabled so you can "adb
|
|
||||||
// push" packages to the sdcard and immediately install them.
|
|
||||||
ensure_path_mounted(SDCARD_ROOT);
|
|
||||||
prompt_and_wait();
|
prompt_and_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ void load_volume_table() {
|
|||||||
int alloc = 2;
|
int alloc = 2;
|
||||||
device_volumes = malloc(alloc * sizeof(Volume));
|
device_volumes = malloc(alloc * sizeof(Volume));
|
||||||
|
|
||||||
|
// Insert an entry for /tmp, which is the ramdisk and is always mounted.
|
||||||
|
device_volumes[0].mount_point = "/tmp";
|
||||||
|
device_volumes[0].fs_type = "ramdisk";
|
||||||
|
device_volumes[0].device = NULL;
|
||||||
|
device_volumes[0].device2 = NULL;
|
||||||
|
num_volumes = 1;
|
||||||
|
|
||||||
FILE* fstab = fopen("/etc/recovery.fstab", "r");
|
FILE* fstab = fopen("/etc/recovery.fstab", "r");
|
||||||
if (fstab == NULL) {
|
if (fstab == NULL) {
|
||||||
LOGE("failed to open /etc/recovery.fstab (%s)\n", strerror(errno));
|
LOGE("failed to open /etc/recovery.fstab (%s)\n", strerror(errno));
|
||||||
@@ -104,6 +111,10 @@ int ensure_path_mounted(const char* path) {
|
|||||||
LOGE("unknown volume for path [%s]\n", path);
|
LOGE("unknown volume for path [%s]\n", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (strcmp(v->fs_type, "ramdisk") == 0) {
|
||||||
|
// the ramdisk is always mounted.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
result = scan_mounted_volumes();
|
result = scan_mounted_volumes();
|
||||||
@@ -160,6 +171,10 @@ int ensure_path_unmounted(const char* path) {
|
|||||||
LOGE("unknown volume for path [%s]\n", path);
|
LOGE("unknown volume for path [%s]\n", path);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (strcmp(v->fs_type, "ramdisk") == 0) {
|
||||||
|
// the ramdisk is always mounted; you can't unmount it.
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
result = scan_mounted_volumes();
|
result = scan_mounted_volumes();
|
||||||
@@ -184,6 +199,11 @@ int format_volume(const char* volume) {
|
|||||||
LOGE("unknown volume \"%s\"\n", volume);
|
LOGE("unknown volume \"%s\"\n", volume);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (strcmp(v->fs_type, "ramdisk") == 0) {
|
||||||
|
// you can't format the ramdisk.
|
||||||
|
LOGE("can't format_volume \"%s\"", volume);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (strcmp(v->mount_point, volume) != 0) {
|
if (strcmp(v->mount_point, volume) != 0) {
|
||||||
LOGE("can't give path \"%s\" to format_volume\n", volume);
|
LOGE("can't give path \"%s\" to format_volume\n", volume);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user