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
This commit is contained in:
Jeff Sharkey 2015-06-26 11:16:14 -07:00
parent 66270a21df
commit 63123c067a

View file

@ -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 @@ status_t Disk::readPartitions() {
}
}
#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;