Use exFAT for SDXC cards
When both VFAT and exFAT are supported VFAT will only be used to format card. Use exFAT for cards larger than 32GB per SDXC standard. Test: build, manual, mount exFAT volume Bug: 80202067 Change-Id: If504f9685256a669c5801a69d69d5a214ad27455
This commit is contained in:
parent
625dc787c6
commit
4cff06d45f
1 changed files with 41 additions and 16 deletions
|
@ -246,28 +246,53 @@ status_t PublicVolume::doUnmount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t PublicVolume::doFormat(const std::string& fsType) {
|
status_t PublicVolume::doFormat(const std::string& fsType) {
|
||||||
if ((fsType == "vfat" || fsType == "auto") && vfat::IsSupported()) {
|
bool useVfat = vfat::IsSupported();
|
||||||
if (WipeBlockDevice(mDevPath) != OK) {
|
bool useExfat = exfat::IsSupported();
|
||||||
LOG(WARNING) << getId() << " failed to wipe";
|
status_t res = OK;
|
||||||
|
|
||||||
|
// Resolve the target filesystem type
|
||||||
|
if (fsType == "auto" && useVfat && useExfat) {
|
||||||
|
uint64_t size = 0;
|
||||||
|
|
||||||
|
res = GetBlockDevSize(mDevPath, &size);
|
||||||
|
if (res != OK) {
|
||||||
|
LOG(ERROR) << "Couldn't get device size " << mDevPath;
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
if (vfat::Format(mDevPath, 0)) {
|
|
||||||
LOG(ERROR) << getId() << " failed to format";
|
// If both vfat & exfat are supported use exfat for SDXC (>~32GiB) cards
|
||||||
return -errno;
|
if (size > 32896LL * 1024 * 1024) {
|
||||||
|
useVfat = false;
|
||||||
|
} else {
|
||||||
|
useExfat = false;
|
||||||
}
|
}
|
||||||
} else if ((fsType == "exfat" || fsType == "auto") && exfat::IsSupported()) {
|
} else if (fsType == "vfat") {
|
||||||
if (WipeBlockDevice(mDevPath) != OK) {
|
useExfat = false;
|
||||||
LOG(WARNING) << getId() << " failed to wipe";
|
} else if (fsType == "exfat") {
|
||||||
}
|
useVfat = false;
|
||||||
if (exfat::Format(mDevPath)) {
|
}
|
||||||
LOG(ERROR) << getId() << " failed to format";
|
|
||||||
return -errno;
|
if (!useVfat && !useExfat) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOG(ERROR) << "Unsupported filesystem " << fsType;
|
LOG(ERROR) << "Unsupported filesystem " << fsType;
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
if (WipeBlockDevice(mDevPath) != OK) {
|
||||||
|
LOG(WARNING) << getId() << " failed to wipe";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useVfat) {
|
||||||
|
res = vfat::Format(mDevPath, 0);
|
||||||
|
} else if (useExfat) {
|
||||||
|
res = exfat::Format(mDevPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res != OK) {
|
||||||
|
LOG(ERROR) << getId() << " failed to format";
|
||||||
|
res = -errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace vold
|
} // namespace vold
|
||||||
|
|
Loading…
Reference in a new issue