diff options
author | bigbiff bigbiff <bigbiff@teamw.in> | 2013-02-23 02:55:50 +0100 |
---|---|---|
committer | bigbiff bigbiff <bigbiff@teamw.in> | 2013-02-25 15:06:46 +0100 |
commit | e60683a0d553b6488c564863f4e48954944fb0f8 (patch) | |
tree | 9364f97cb88b7c1359f5f06dfb32150a78168c31 /partition.cpp | |
parent | Fix building of updater for 4.2 environment (diff) | |
download | android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.gz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.bz2 android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.lz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.xz android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.tar.zst android_bootable_recovery-e60683a0d553b6488c564863f4e48954944fb0f8.zip |
Diffstat (limited to '')
-rw-r--r-- | partition.cpp | 72 |
1 files changed, 14 insertions, 58 deletions
diff --git a/partition.cpp b/partition.cpp index 6070775c3..e158e0ab8 100644 --- a/partition.cpp +++ b/partition.cpp @@ -35,6 +35,7 @@ #include "cutils/properties.h" #endif +#include "libblkid/blkid.h" #include "variables.h" #include "common.h" #include "partitions.hpp" @@ -284,11 +285,6 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) { 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)) { @@ -1050,12 +1046,8 @@ bool TWPartition::Wipe_Encryption() { } void TWPartition::Check_FS_Type() { - string blkCommand, result; - string blkOutput; - char* blk; - char* arg; - char* ptr; - int type_found = 0; + const char* type; + blkid_probe pr; if (Fstab_File_System == "yaffs2" || Fstab_File_System == "mtd" || Fstab_File_System == "bml" || Ignore_Blkid) return; // Running blkid on some mtd devices causes a massive crash or needs to be skipped @@ -1064,54 +1056,18 @@ void TWPartition::Check_FS_Type() { if (!Is_Present) return; - blkCommand = "blkid " + Actual_Block_Device; - TWFunc::Exec_Cmd(blkCommand, result); - std::stringstream line(result); - while (getline(line, blkOutput)) - { - blk = (char*) blkOutput.c_str(); - ptr = (char*) blkOutput.c_str(); - while (*ptr > 32 && *ptr != ':') ptr++; - if (*ptr == 0) continue; - *ptr = 0; - - // Increment by two, but verify that we don't hit a NULL - ptr++; - if (*ptr != 0) ptr++; - - // Now, find the TYPE field - while (1) - { - arg = ptr; - while (*ptr > 32) ptr++; - if (*ptr != 0) { - *ptr = 0; - ptr++; - } - - if (strlen(arg) > 6) { - if (memcmp(arg, "TYPE=\"", 6) == 0) { - type_found = 1; - break; - } - } - - if (*ptr == 0) { - arg = NULL; - break; - } - } - - if (type_found) { - arg += 6; // Skip the TYPE=" portion - arg[strlen(arg)-1] = '\0'; // Drop the tail quote - if (Current_File_System != arg) { - LOGI("'%s' was '%s' now set to '%s'\n", Mount_Point.c_str(), Current_File_System.c_str(), arg); - Current_File_System = arg; - } - } else - continue; + pr = blkid_new_probe_from_filename(Actual_Block_Device.c_str()); + if (blkid_do_fullprobe(pr)) { + blkid_free_probe(pr); + LOGI("Can't probe device %s\n", Actual_Block_Device.c_str()); + return; + } + if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL) < 0) { + blkid_free_probe(pr); + LOGI("can't find filesystem on device %s\n", Actual_Block_Device.c_str()); + return; } + Current_File_System = type; return; } |