Add method to forget private partition keys.
Report both the disk and the partition GUID for private volumes to
userspace, and offer to forget the encryption key for a given
partition GUID.
Bug: 21782268
Change-Id: Ie77a3a58e47bf3563cdb3e4b0edfab1de4d0e6b4
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 6f783a2..f1667f2 100755
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -59,6 +59,7 @@
#include "Asec.h"
#include "VoldUtil.h"
#include "cryptfs.h"
+#include "fstrim.h"
#define MASS_STORAGE_FILE_PATH "/sys/class/android_usb/android0/f_mass_storage/lun/file"
@@ -405,6 +406,22 @@
return android::vold::Benchmark(path, sysPath);
}
+int VolumeManager::forgetPartition(const std::string& partGuid) {
+ std::string normalizedGuid;
+ if (android::vold::NormalizeHex(partGuid, normalizedGuid)) {
+ LOG(WARNING) << "Invalid GUID " << partGuid;
+ return -1;
+ }
+
+ std::string keyPath = android::vold::BuildKeyPath(normalizedGuid);
+ if (unlink(keyPath.c_str()) != 0) {
+ LOG(ERROR) << "Failed to unlink " << keyPath;
+ return -1;
+ }
+
+ return 0;
+}
+
int VolumeManager::linkPrimary(userid_t userId) {
std::string source(mPrimary->getPath());
if (mPrimary->getType() == android::vold::VolumeBase::Type::kEmulated) {