summaryrefslogtreecommitdiffstats
path: root/fs_mgr
diff options
context:
space:
mode:
authorPaul Crowley <paulcrowley@google.com>2018-02-02 14:41:34 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-02-02 14:41:34 +0000
commitdf68df87f2c23ed2abb8898295dfc27ec77365e9 (patch)
tree0bb2c108139f0b0e5f41aa0e790c519e180d7735 /fs_mgr
parent9e96d851d6e56fb0478bb1fe175d262f039f1d90 (diff)
parent2c90b91203476d4ceac4e40df689848841bbeeaf (diff)
downloadsystem_core-df68df87f2c23ed2abb8898295dfc27ec77365e9.tar.gz
system_core-df68df87f2c23ed2abb8898295dfc27ec77365e9.tar.bz2
system_core-df68df87f2c23ed2abb8898295dfc27ec77365e9.zip
Merge "Use vold's mount with metadata encryption service." am: 4819edf4fc am: fcc1db2189
am: 2c90b91203 Change-Id: I545e40be18e2e2aca925dd3423e9b0dd5136f658
Diffstat (limited to 'fs_mgr')
-rw-r--r--fs_mgr/fs_mgr.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/fs_mgr/fs_mgr.cpp b/fs_mgr/fs_mgr.cpp
index a2b80ad9f..9aab0bac4 100644
--- a/fs_mgr/fs_mgr.cpp
+++ b/fs_mgr/fs_mgr.cpp
@@ -32,11 +32,14 @@
#include <unistd.h>
#include <memory>
+#include <string>
#include <thread>
+#include <vector>
#include <android-base/file.h>
#include <android-base/properties.h>
#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/android_filesystem_config.h>
#include <cutils/android_reboot.h>
@@ -775,6 +778,22 @@ static int handle_encryptable(const struct fstab_rec* rec)
}
}
+static bool call_vdc(const std::vector<std::string>& args) {
+ std::vector<char const*> argv;
+ argv.emplace_back("/system/bin/vdc");
+ for (auto& arg : args) {
+ argv.emplace_back(arg.c_str());
+ }
+ LOG(INFO) << "Calling: " << android::base::Join(argv, ' ');
+ int ret = android_fork_execvp(4, const_cast<char**>(argv.data()), nullptr, false, true);
+ if (ret != 0) {
+ LOG(ERROR) << "vdc returned error code: " << ret;
+ return false;
+ }
+ LOG(DEBUG) << "vdc finished successfully";
+ return true;
+}
+
/* When multiple fstab records share the same mount_point, it will
* try to mount each one in turn, and ignore any duplicates after a
* first successful mount.
@@ -881,6 +900,13 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
LERROR << "Only one encryptable/encrypted partition supported";
}
encryptable = status;
+ if (status == FS_MGR_MNTALL_DEV_NEEDS_METADATA_ENCRYPTION) {
+ if (!call_vdc(
+ {"cryptfs", "encryptFstab", fstab->recs[attempted_idx].mount_point})) {
+ LERROR << "Encryption failed";
+ return FS_MGR_MNTALL_FAIL;
+ }
+ }
}
/* Success! Go get the next one */
@@ -955,7 +981,11 @@ int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
} else if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
should_use_metadata_encryption(&fstab->recs[attempted_idx])) {
+ if (!call_vdc({"cryptfs", "mountFstab", fstab->recs[attempted_idx].mount_point})) {
+ ++error_count;
+ }
encryptable = FS_MGR_MNTALL_DEV_IS_METADATA_ENCRYPTED;
+ continue;
} else {
// fs_options might be null so we cannot use PERROR << directly.
// Use StringPrintf to output "(null)" instead.