exFAT improvements, fixes

Move Exec_Cmd to libcrecovery __popen
Provide opt out build flag for exFAT
Default fstype to exfat on external storage if exfat support is
present and fstype is vfat or auto
Fix invalid unmount errors
Improve handling of unencrypted sdcards on Samsung devices
This commit is contained in:
Dees_Troy
2013-01-28 20:45:11 +00:00
parent 2c4c26f43d
commit b05ddeedd3
4 changed files with 32 additions and 16 deletions
+7 -7
View File
@@ -62,7 +62,7 @@ LOCAL_C_INCLUDES += bionic external/stlport/stlport
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES :=
LOCAL_STATIC_LIBRARIES += libmtdutils
LOCAL_STATIC_LIBRARIES += libmtdutils libcrecovery
LOCAL_STATIC_LIBRARIES += libminadbd libminzip libunz
LOCAL_STATIC_LIBRARIES += libminuitwrp libpixelflinger_static libpng libjpegtwrp libgui
LOCAL_SHARED_LIBRARIES += libz libc libstlport libcutils libstdc++ libmincrypt libext4_utils libtar
@@ -282,10 +282,7 @@ include $(commands_recovery_local_path)/libjpegtwrp/Android.mk \
$(commands_recovery_local_path)/crypto/cryptsettings/Android.mk \
$(commands_recovery_local_path)/crypto/cryptfs/Android.mk \
$(commands_recovery_local_path)/libcrecovery/Android.mk \
$(commands_recovery_local_path)/twmincrypt/Android.mk \
$(commands_recovery_local_path)/exfat/mkfs/Android.mk \
$(commands_recovery_local_path)/fuse/Android.mk \
$(commands_recovery_local_path)/exfat/libexfat/Android.mk
$(commands_recovery_local_path)/twmincrypt/Android.mk
ifeq ($(TW_INCLUDE_CRYPTO_SAMSUNG), true)
include $(commands_recovery_local_path)/crypto/libcrypt_samsung/Android.mk
@@ -295,8 +292,11 @@ ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
include $(commands_recovery_local_path)/crypto/fs_mgr/Android.mk
endif
ifeq ($(TW_INCLUDE_FUSE_EXFAT), true)
include $(commands_recovery_local_path)/exfat/exfat-fuse/Android.mk
ifneq ($(TW_NO_EXFAT), true)
include $(commands_recovery_local_path)/exfat/exfat-fuse/Android.mk \
$(commands_recovery_local_path)/exfat/mkfs/Android.mk \
$(commands_recovery_local_path)/fuse/Android.mk \
$(commands_recovery_local_path)/exfat/libexfat/Android.mk
endif
commands_recovery_local_path :=
+11 -3
View File
@@ -274,7 +274,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Is_Storage = true;
Storage_Path = EXPAND(TW_EXTERNAL_STORAGE_PATH);
Removable = true;
}
#else
if (Mount_Point == "/sdcard") {
Is_Storage = true;
@@ -284,8 +283,13 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
Setup_AndSec();
Mount_Storage_Retry();
#endif
}
#endif
// blkid cannot detect exfat so we force exfat at the start if exfat support is present
if (TWFunc::Path_Exists("/sbin/exfat-fuse") && (Fstab_File_System == "vfat" || Fstab_File_System == "auto")) {
Fstab_File_System = "exfat";
Current_File_System = Fstab_File_System;
}
}
#ifdef TW_INTERNAL_STORAGE_PATH
if (Mount_Point == EXPAND(TW_INTERNAL_STORAGE_PATH)) {
Is_Storage = true;
@@ -718,7 +722,10 @@ bool TWPartition::Mount(bool Display_Error) {
LOGI("Unable to mount ecryptfs for '%s'\n", Mount_Point.c_str());
} else {
LOGI("Successfully mounted ecryptfs for '%s'\n", Mount_Point.c_str());
Is_Decrypted = true;
}
} else {
Is_Decrypted = false;
}
#endif
if (Removable)
@@ -758,7 +765,8 @@ bool TWPartition::UnMount(bool Display_Error) {
if (!Symlink_Mount_Point.empty())
umount(Symlink_Mount_Point.c_str());
if (umount(Mount_Point.c_str()) != 0) {
umount(Mount_Point.c_str());
if (Is_Mounted()) {
if (Display_Error)
LOGE("Unable to unmount '%s'\n", Mount_Point.c_str());
else
+2 -2
View File
@@ -44,10 +44,10 @@ RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libflashutils.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libstlport.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libmincrypt.so
RELINK_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libext4_utils.so
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkexfatfs
ifeq ($(TW_INCLUDE_FUSE_EXFAT), true)
ifneq ($(TW_NO_EXFAT), true)
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/exfat-fuse
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/mkexfatfs
endif
ifeq ($(TW_INCLUDE_BLOBPACK), true)
RELINK_SOURCE_FILES += $(TARGET_RECOVERY_ROOT_OUT)/sbin/blobpack
+12 -4
View File
@@ -21,20 +21,28 @@
#include "bootloader.h"
#include "variables.h"
extern "C" {
#include "libcrecovery/common.h"
}
/* Execute a command */
int TWFunc::Exec_Cmd(string cmd, string &result) {
FILE* exec;
char buffer[128];
char buffer[130];
int ret = 0;
exec = popen(cmd.c_str(), "r");
exec = __popen(cmd.c_str(), "r");
if (!exec) return -1;
while(!feof(exec)) {
if (fgets(buffer, 128, exec) != NULL)
memset(&buffer, 0, sizeof(buffer));
if (fgets(buffer, 128, exec) != NULL) {
buffer[128] = '\n';
buffer[129] = NULL;
result += buffer;
}
}
ret = pclose(exec);
ret = __pclose(exec);
return ret;
}