summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2013-06-19 18:24:30 +0200
committerGerrit Code Review <gerrit@5.9.244.119>2013-07-01 22:36:02 +0200
commit76543db6e60948b2ac3f66c70f4262c1c0dee05a (patch)
tree0ee541574dcf070e275866d1eda093af57265ac2
parentMerge "Update init.rc to fix sideload" into twrp2.5 (diff)
downloadandroid_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar.gz
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar.bz2
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar.lz
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar.xz
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.tar.zst
android_bootable_recovery-76543db6e60948b2ac3f66c70f4262c1c0dee05a.zip
-rw-r--r--Android.mk2
-rw-r--r--partition.cpp51
2 files changed, 37 insertions, 16 deletions
diff --git a/Android.mk b/Android.mk
index 7aa6decbb..1471db1b1 100644
--- a/Android.mk
+++ b/Android.mk
@@ -276,7 +276,7 @@ LOCAL_MODULE := libaosprecovery
LOCAL_MODULE_TAGS := eng
LOCAL_MODULES_TAGS = optional
LOCAL_CFLAGS =
-LOCAL_SRC_FILES = adb_install.cpp bootloader.cpp verifier.cpp
+LOCAL_SRC_FILES = adb_install.cpp bootloader.cpp verifier.cpp mtdutils/mtdutils.c
LOCAL_SHARED_LIBRARIES += libc liblog libcutils libmtdutils
LOCAL_STATIC_LIBRARIES += libmincrypt
diff --git a/partition.cpp b/partition.cpp
index f92d62f21..9ab60ba9a 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -637,6 +637,8 @@ bool TWPartition::Find_MTD_Block_Device(string MTD_Name) {
if (sscanf(device,"mtd%d", &deviceId) == 1) {
sprintf(device, "/dev/block/mtdblock%d", deviceId);
Primary_Block_Device = device;
+ fclose(fp);
+ return true;
}
}
}
@@ -828,22 +830,41 @@ bool TWPartition::Mount(bool Display_Error) {
}
if (Fstab_File_System == "yaffs2") {
// mount an MTD partition as a YAFFS2 filesystem.
- mtd_scan_partitions();
- const MtdPartition* partition;
- partition = mtd_find_partition_by_name(MTD_Name.c_str());
- if (partition == NULL) {
- LOGERR("Failed to find '%s' partition to mount at '%s'\n",
- MTD_Name.c_str(), Mount_Point.c_str());
- return false;
- }
- if (mtd_mount_partition(partition, Mount_Point.c_str(), Fstab_File_System.c_str(), 0)) {
- if (Display_Error)
- LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
- else
- LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
- return false;
- } else
+ const unsigned long flags = MS_NOATIME | MS_NODEV | MS_NODIRATIME;
+ if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Fstab_File_System.c_str(), flags, NULL) < 0) {
+ if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Fstab_File_System.c_str(), flags | MS_RDONLY, NULL) < 0) {
+ if (Display_Error)
+ LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ else
+ LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ return false;
+ } else {
+ LOGINFO("Mounted '%s' (MTD) as RO\n", Mount_Point.c_str());
+ return true;
+ }
+ } else {
+ struct stat st;
+ string test_path = Mount_Point;
+ if (stat(test_path.c_str(), &st) < 0) {
+ if (Display_Error)
+ LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ else
+ LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
+ return false;
+ }
+ mode_t new_mode = st.st_mode | S_IXUSR | S_IXGRP | S_IXOTH;
+ if (new_mode != st.st_mode) {
+ LOGINFO("Fixing execute permissions for %s\n", Mount_Point.c_str());
+ if (chmod(Mount_Point.c_str(), new_mode) < 0) {
+ if (Display_Error)
+ LOGERR("Couldn't fix permissions for %s: %s\n", Mount_Point.c_str(), strerror(errno));
+ else
+ LOGINFO("Couldn't fix permissions for %s: %s\n", Mount_Point.c_str(), strerror(errno));
+ return false;
+ }
+ }
return true;
+ }
} else if (!exfat_mounted && mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
#ifdef TW_NO_EXFAT_FUSE
if (Current_File_System == "exfat") {