summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author cjbao <cathy.bao@intel.com> 2017-04-12 00:12:24 +0800
committer cjbao <cathy.bao@intel.com> 2017-04-18 20:02:26 +0800
commit75d4e57dfa11a5fcc99a260facf71309945ade67 (patch)
tree666a26af5184df3a85d63f620331f3c71ffb065c
parentcf617abcb242313e8b1407486d00a041415ba196 (diff)
installd create_data_user_ce_path uses dir instead of symlink
Select whichever is real dir instead of symbolic link from either /data/data or /data/user/0. This is to minimize path walking overhead in kernel. Test: Manual test Change-Id: Ie06640624746ff40a2b5b47ead50a7f10eb2db3e Signed-off-by: cjbao <cathy.bao@intel.com>
-rw-r--r--cmds/installd/utils.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/cmds/installd/utils.cpp b/cmds/installd/utils.cpp
index bdd62e6554..6747f0ad51 100644
--- a/cmds/installd/utils.cpp
+++ b/cmds/installd/utils.cpp
@@ -170,18 +170,19 @@ std::string create_data_app_path(const char* volume_uuid) {
/**
* Create the path name for user data for a certain userid.
+ * Keep same implementation as vold to minimize path walking overhead
*/
std::string create_data_user_ce_path(const char* volume_uuid, userid_t userid) {
std::string data(create_data_path(volume_uuid));
- if (volume_uuid == nullptr) {
- if (userid == 0) {
- return StringPrintf("%s/data", data.c_str());
- } else {
- return StringPrintf("%s/user/%u", data.c_str(), userid);
+ if (volume_uuid == nullptr && userid == 0) {
+ std::string legacy = StringPrintf("%s/data", data.c_str());
+ struct stat sb;
+ if (lstat(legacy.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) {
+ /* /data/data is dir, return /data/data for legacy system */
+ return legacy;
}
- } else {
- return StringPrintf("%s/user/%u", data.c_str(), userid);
}
+ return StringPrintf("%s/user/%u", data.c_str(), userid);
}
/**