Fix MTD Mounting

Pulled part of change from kokotas in this patch set:
http://review.teamw.in/#/c/586/

Change-Id: If1c5b1563df16f9c561c94f61010f6a99f36efa0
This commit is contained in:
Dees_Troy
2013-06-19 16:24:30 +00:00
committed by Gerrit Code Review
parent ee4b6c8112
commit 76543db6e6
2 changed files with 37 additions and 16 deletions
+1 -1
View File
@@ -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
+36 -15
View File
@@ -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") {