summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-08-06 07:28:46 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-08-06 07:28:46 +0000
commit06ed6915b058fda8a61a94d736d91cd5d1e3cf7a (patch)
treeb813f052b16ea159572eaf093a19dabcd3aefa76
parent48d07a7d9f3c80c3d4e8a859cb183f97901ecfcb (diff)
parent53deec14b8418abbc1a6f30ff89629710437279f (diff)
downloadvold-06ed6915b058fda8a61a94d736d91cd5d1e3cf7a.tar.gz
release-request-d642586e-3e25-49f4-8b4c-acad0e3f63d8-for-git_oc-mr1-release-4249777 snap-temp-L81500000089724408
Change-Id: Id337b6c2c8fc8f38b0aaae21216262c70a7f0bf0
-rw-r--r--Ext4Crypt.cpp12
-rw-r--r--Utils.cpp15
-rw-r--r--VolumeManager.cpp4
-rw-r--r--VolumeManager.h3
-rw-r--r--fs/Vfat.cpp2
5 files changed, 28 insertions, 8 deletions
diff --git a/Ext4Crypt.cpp b/Ext4Crypt.cpp
index 13cff0dc..f9d4cf8b 100644
--- a/Ext4Crypt.cpp
+++ b/Ext4Crypt.cpp
@@ -30,6 +30,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
+#include <unistd.h>
#include <limits.h>
#include <selinux/android.h>
#include <sys/mount.h>
@@ -54,6 +55,7 @@
#include <android-base/stringprintf.h>
using android::base::StringPrintf;
+using android::base::WriteStringToFile;
using android::vold::kEmptyAuthentication;
// NOTE: keep in sync with StorageManager
@@ -399,6 +401,15 @@ bool e4crypt_vold_create_user_key(userid_t user_id, int serial, bool ephemeral)
return true;
}
+static void drop_caches() {
+ // Clean any dirty pages (otherwise they won't be dropped).
+ sync();
+ // Drop inode and page caches.
+ if (!WriteStringToFile("3", "/proc/sys/vm/drop_caches")) {
+ PLOG(ERROR) << "Failed to drop caches during key eviction";
+ }
+}
+
static bool evict_ce_key(userid_t user_id) {
s_ce_keys.erase(user_id);
bool success = true;
@@ -406,6 +417,7 @@ static bool evict_ce_key(userid_t user_id) {
// If we haven't loaded the CE key, no need to evict it.
if (lookup_key_ref(s_ce_key_raw_refs, user_id, &raw_ref)) {
success &= android::vold::evictKey(raw_ref);
+ drop_caches();
}
s_ce_key_raw_refs.erase(user_id);
return success;
diff --git a/Utils.cpp b/Utils.cpp
index 9699777e..395a8901 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -17,6 +17,7 @@
#include "sehandle.h"
#include "Utils.h"
#include "Process.h"
+#include "VolumeManager.h"
#include <android-base/file.h>
#include <android-base/logging.h>
@@ -126,22 +127,22 @@ status_t ForceUnmount(const std::string& path) {
}
// Apps might still be handling eject request, so wait before
// we start sending signals
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
Process::killProcessesWithOpenFiles(cpath, SIGINT);
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
return OK;
}
Process::killProcessesWithOpenFiles(cpath, SIGTERM);
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
return OK;
}
Process::killProcessesWithOpenFiles(cpath, SIGKILL);
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
if (!umount2(cpath, UMOUNT_NOFOLLOW) || errno == EINVAL || errno == ENOENT) {
return OK;
}
@@ -154,17 +155,17 @@ status_t KillProcessesUsingPath(const std::string& path) {
if (Process::killProcessesWithOpenFiles(cpath, SIGINT) == 0) {
return OK;
}
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
if (Process::killProcessesWithOpenFiles(cpath, SIGTERM) == 0) {
return OK;
}
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
if (Process::killProcessesWithOpenFiles(cpath, SIGKILL) == 0) {
return OK;
}
- sleep(5);
+ if (!VolumeManager::shutting_down) sleep(5);
// Send SIGKILL a second time to determine if we've
// actually killed everyone with open files
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 4ba0c366..83984987 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -89,6 +89,8 @@ const char *VolumeManager::ASECDIR = "/mnt/asec";
*/
const char *VolumeManager::LOOPDIR = "/mnt/obb";
+bool VolumeManager::shutting_down = false;
+
static const char* kPathUserMount = "/mnt/user";
static const char* kPathVirtualDisk = "/data/misc/vold/virtual_disk";
@@ -704,12 +706,14 @@ int VolumeManager::shutdown() {
if (mInternalEmulated == nullptr) {
return 0; // already shutdown
}
+ shutting_down = true;
mInternalEmulated->destroy();
mInternalEmulated = nullptr;
for (const auto& disk : mDisks) {
disk->destroy();
}
mDisks.clear();
+ shutting_down = false;
return 0;
}
diff --git a/VolumeManager.h b/VolumeManager.h
index 796a91d3..537aebe1 100644
--- a/VolumeManager.h
+++ b/VolumeManager.h
@@ -70,6 +70,9 @@ public:
static const char *ASECDIR;
static const char *LOOPDIR;
+ //TODO remove this with better solution, b/64143519
+ static bool shutting_down;
+
private:
static VolumeManager *sInstance;
diff --git a/fs/Vfat.cpp b/fs/Vfat.cpp
index 1803c4b8..dc1fe331 100644
--- a/fs/Vfat.cpp
+++ b/fs/Vfat.cpp
@@ -133,7 +133,7 @@ status_t Mount(const std::string& source, const std::string& target, bool ro,
const char* c_source = source.c_str();
const char* c_target = target.c_str();
- flags = MS_NODEV | MS_NOSUID | MS_DIRSYNC;
+ flags = MS_NODEV | MS_NOSUID | MS_DIRSYNC | MS_NOATIME;
flags |= (executable ? 0 : MS_NOEXEC);
flags |= (ro ? MS_RDONLY : 0);