From b05ddeedd383e3dab9e45b174e9e3f3cb6cd1ea5 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Mon, 28 Jan 2013 20:24:50 +0000 Subject: 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 --- twrp-functions.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'twrp-functions.cpp') diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 5473c8d66..0c4471ac7 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -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; } -- cgit v1.2.3