Last ditch check for partition on raw disk.
Some storage devices can be formatted as bare partitions, without an
MBR or GPT header. If we found no partitions, try poking at the raw
disk, and treat it as a public volume if we found a valid filesystem.
Bug: 20503551
Change-Id: I80304e1ad865435321c341b667c0daf2daf4d56c
diff --git a/Disk.cpp b/Disk.cpp
index c680a43..df53d07 100644
--- a/Disk.cpp
+++ b/Disk.cpp
@@ -36,8 +36,6 @@
#include <sys/stat.h>
#include <sys/mount.h>
-#define ENTIRE_DEVICE_FALLBACK 0
-
using android::base::ReadFileToString;
using android::base::WriteStringToFile;
using android::base::StringPrintf;
@@ -306,14 +304,18 @@
}
}
-#if ENTIRE_DEVICE_FALLBACK
// Ugly last ditch effort, treat entire disk as partition
if (table == Table::kUnknown || !foundParts) {
- // TODO: use blkid to confirm filesystem before doing this
LOG(WARNING) << mId << " has unknown partition table; trying entire device";
- createPublicVolume(mDevice);
+
+ std::string fsType;
+ std::string unused;
+ if (ReadMetadataUntrusted(mDevPath, fsType, unused, unused) == OK) {
+ createPublicVolume(mDevice);
+ } else {
+ LOG(WARNING) << mId << " failed to identify, giving up";
+ }
}
-#endif
notifyEvent(ResponseCode::DiskScanned);
mJustPartitioned = false;