recovery: Allow "Mount /system" for system_root_image.
When system images contain the root directory, there is no entry of
"/system" in the fstab. Change it to look for "/" instead if
ro.build.system_root_image is true. We actually mount the partition
to /system_root instead, and create a symlink to /system_root/system
for /system. This allows "adb shell" to work properly.
Bug: 22855115
Change-Id: I91864444950dc3229fda3cc133ddbadeb8817fb8
(cherry picked from commit abb8f7785e
)
This commit is contained in:
parent
32ac97675b
commit
8f90389966
3 changed files with 39 additions and 19 deletions
15
recovery.cpp
15
recovery.cpp
|
@ -862,9 +862,24 @@ prompt_and_wait(Device* device, int status) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Device::MOUNT_SYSTEM:
|
case Device::MOUNT_SYSTEM:
|
||||||
|
char system_root_image[PROPERTY_VALUE_MAX];
|
||||||
|
property_get("ro.build.system_root_image", system_root_image, "");
|
||||||
|
|
||||||
|
// For a system image built with the root directory (i.e.
|
||||||
|
// system_root_image == "true"), we mount it to /system_root, and symlink /system
|
||||||
|
// to /system_root/system to make adb shell work (the symlink is created through
|
||||||
|
// the build system).
|
||||||
|
// Bug: 22855115
|
||||||
|
if (strcmp(system_root_image, "true") == 0) {
|
||||||
|
if (ensure_path_mounted_at("/", "/system_root") != -1) {
|
||||||
|
ui->Print("Mounted /system.\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (ensure_path_mounted("/system") != -1) {
|
if (ensure_path_mounted("/system") != -1) {
|
||||||
ui->Print("Mounted /system.\n");
|
ui->Print("Mounted /system.\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
roots.cpp
26
roots.cpp
|
@ -70,7 +70,8 @@ Volume* volume_for_path(const char* path) {
|
||||||
return fs_mgr_get_entry_for_mount_point(fstab, path);
|
return fs_mgr_get_entry_for_mount_point(fstab, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ensure_path_mounted(const char* path) {
|
// Mount the volume specified by path at the given mount_point.
|
||||||
|
int ensure_path_mounted_at(const char* path, const char* mount_point) {
|
||||||
Volume* v = volume_for_path(path);
|
Volume* v = volume_for_path(path);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
LOGE("unknown volume for path [%s]\n", path);
|
LOGE("unknown volume for path [%s]\n", path);
|
||||||
|
@ -88,14 +89,18 @@ int ensure_path_mounted(const char* path) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!mount_point) {
|
||||||
|
mount_point = v->mount_point;
|
||||||
|
}
|
||||||
|
|
||||||
const MountedVolume* mv =
|
const MountedVolume* mv =
|
||||||
find_mounted_volume_by_mount_point(v->mount_point);
|
find_mounted_volume_by_mount_point(mount_point);
|
||||||
if (mv) {
|
if (mv) {
|
||||||
// volume is already mounted
|
// volume is already mounted
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir(v->mount_point, 0755); // in case it doesn't already exist
|
mkdir(mount_point, 0755); // in case it doesn't already exist
|
||||||
|
|
||||||
if (strcmp(v->fs_type, "yaffs2") == 0) {
|
if (strcmp(v->fs_type, "yaffs2") == 0) {
|
||||||
// mount an MTD partition as a YAFFS2 filesystem.
|
// mount an MTD partition as a YAFFS2 filesystem.
|
||||||
|
@ -104,25 +109,30 @@ int ensure_path_mounted(const char* path) {
|
||||||
partition = mtd_find_partition_by_name(v->blk_device);
|
partition = mtd_find_partition_by_name(v->blk_device);
|
||||||
if (partition == NULL) {
|
if (partition == NULL) {
|
||||||
LOGE("failed to find \"%s\" partition to mount at \"%s\"\n",
|
LOGE("failed to find \"%s\" partition to mount at \"%s\"\n",
|
||||||
v->blk_device, v->mount_point);
|
v->blk_device, mount_point);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return mtd_mount_partition(partition, v->mount_point, v->fs_type, 0);
|
return mtd_mount_partition(partition, mount_point, v->fs_type, 0);
|
||||||
} else if (strcmp(v->fs_type, "ext4") == 0 ||
|
} else if (strcmp(v->fs_type, "ext4") == 0 ||
|
||||||
strcmp(v->fs_type, "squashfs") == 0 ||
|
strcmp(v->fs_type, "squashfs") == 0 ||
|
||||||
strcmp(v->fs_type, "vfat") == 0) {
|
strcmp(v->fs_type, "vfat") == 0) {
|
||||||
result = mount(v->blk_device, v->mount_point, v->fs_type,
|
result = mount(v->blk_device, mount_point, v->fs_type,
|
||||||
v->flags, v->fs_options);
|
v->flags, v->fs_options);
|
||||||
if (result == 0) return 0;
|
if (result == 0) return 0;
|
||||||
|
|
||||||
LOGE("failed to mount %s (%s)\n", v->mount_point, strerror(errno));
|
LOGE("failed to mount %s (%s)\n", mount_point, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, v->mount_point);
|
LOGE("unknown fs_type \"%s\" for %s\n", v->fs_type, mount_point);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ensure_path_mounted(const char* path) {
|
||||||
|
// Mount at the default mount point.
|
||||||
|
return ensure_path_mounted_at(path, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
int ensure_path_unmounted(const char* path) {
|
int ensure_path_unmounted(const char* path) {
|
||||||
Volume* v = volume_for_path(path);
|
Volume* v = volume_for_path(path);
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
|
|
13
roots.h
13
roots.h
|
@ -19,10 +19,6 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Load and parse volume data from /etc/recovery.fstab.
|
// Load and parse volume data from /etc/recovery.fstab.
|
||||||
void load_volume_table();
|
void load_volume_table();
|
||||||
|
|
||||||
|
@ -33,7 +29,10 @@ Volume* volume_for_path(const char* path);
|
||||||
// success (volume is mounted).
|
// success (volume is mounted).
|
||||||
int ensure_path_mounted(const char* path);
|
int ensure_path_mounted(const char* path);
|
||||||
|
|
||||||
// Make sure that the volume 'path' is on is mounted. Returns 0 on
|
// Similar to ensure_path_mounted, but allows one to specify the mount_point.
|
||||||
|
int ensure_path_mounted_at(const char* path, const char* mount_point);
|
||||||
|
|
||||||
|
// Make sure that the volume 'path' is on is unmounted. Returns 0 on
|
||||||
// success (volume is unmounted);
|
// success (volume is unmounted);
|
||||||
int ensure_path_unmounted(const char* path);
|
int ensure_path_unmounted(const char* path);
|
||||||
|
|
||||||
|
@ -46,8 +45,4 @@ int format_volume(const char* volume);
|
||||||
// mounted (/tmp and /cache) are mounted. Returns 0 on success.
|
// mounted (/tmp and /cache) are mounted. Returns 0 on success.
|
||||||
int setup_install_mounts();
|
int setup_install_mounts();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // RECOVERY_ROOTS_H_
|
#endif // RECOVERY_ROOTS_H_
|
||||||
|
|
Loading…
Reference in a new issue