From 4bb33ac46bd5c632b565f95c9845a19e0cccf6a2 Mon Sep 17 00:00:00 2001 From: Dees_Troy Date: Fri, 18 Jan 2013 21:05:47 +0000 Subject: Fix handling of blkid output Fixed handling of blkid output when the output spans multiple lines and the TYPE field ended up on next line. --- partition.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'partition.cpp') diff --git a/partition.cpp b/partition.cpp index 14d5e8490..291f6baa5 100644 --- a/partition.cpp +++ b/partition.cpp @@ -997,6 +997,7 @@ void TWPartition::Check_FS_Type() { char* blk; char* arg; char* ptr; + int type_found = 0; 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 @@ -1025,35 +1026,33 @@ void TWPartition::Check_FS_Type() { { arg = ptr; while (*ptr > 32) ptr++; - if (*ptr != 0) - { + if (*ptr != 0) { *ptr = 0; ptr++; } - if (strlen(arg) > 6) - { - if (memcmp(arg, "TYPE=\"", 6) == 0) break; + if (strlen(arg) > 6) { + if (memcmp(arg, "TYPE=\"", 6) == 0) { + type_found = 1; + break; + } } - if (*ptr == 0) - { + if (*ptr == 0) { arg = NULL; break; } } - if (arg && strlen(arg) > 7) - { + if (type_found) { arg += 6; // Skip the TYPE=" portion arg[strlen(arg)-1] = '\0'; // Drop the tail quote - } - else + 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; - 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; - } } return; } -- cgit v1.2.3