Merge changes I2c1d4b42,I06fe4d33
* changes:
Conditionally use sdcardfs.
Also delay creating found disks until user 0 is started.
diff --git a/EncryptInplace.cpp b/EncryptInplace.cpp
index 3755718..9d304da 100644
--- a/EncryptInplace.cpp
+++ b/EncryptInplace.cpp
@@ -391,6 +391,8 @@
struct encryptGroupsData data;
struct f2fs_info* f2fs_info = NULL;
int rc = ENABLE_INPLACE_ERR_OTHER;
+ struct timespec time_started = {0};
+
if (previously_encrypted_upto > *size_already_done) {
LOG(DEBUG) << "Not fast encrypting since resuming part way through";
return ENABLE_INPLACE_ERR_OTHER;
@@ -423,9 +425,14 @@
data.one_pct = data.tot_used_blocks / 100;
data.cur_pct = 0;
- data.time_started = time(NULL);
+ if (clock_gettime(CLOCK_MONOTONIC, &time_started)) {
+ LOG(WARNING) << "Error getting time at start";
+ // Note - continue anyway - we'll run with 0
+ }
+ data.time_started = time_started.tv_sec;
data.remaining_time = -1;
+
data.buffer = (char*)malloc(f2fs_info->block_size);
if (!data.buffer) {
LOG(ERROR) << "Failed to allocate crypto buffer";
diff --git a/Utils.cpp b/Utils.cpp
index 0375765..46272f6 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -1018,7 +1018,13 @@
StringPrintf("%s/%s", pre_pass_through_path.c_str(), relative_upper_path.c_str()));
// Create directories.
- auto result = PrepareDir(pre_fuse_path, 0700, AID_ROOT, AID_ROOT);
+ // Shell is neither AID_ROOT nor AID_EVERYBODY. Since it equally needs 'execute' access to
+ // /mnt/user/0 to 'adb shell ls /sdcard' for instance, we set the uid bit of /mnt/user/0 to
+ // AID_SHELL. This gives shell access along with apps running as group everybody (user 0 apps)
+ // These bits should be consistent with what is set in zygote in
+ // com_android_internal_os_Zygote#MountEmulatedStorage on volume bind mount during app fork
+ auto result = PrepareDir(pre_fuse_path, 0710, user_id ? AID_ROOT : AID_SHELL,
+ multiuser_get_uid(user_id, AID_EVERYBODY));
if (result != android::OK) {
PLOG(ERROR) << "Failed to prepare directory " << pre_fuse_path;
return -1;
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 4d850fb..98cb060 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -829,13 +829,21 @@
return -EINVAL;
}
+ // Convert paths to lower filesystem paths to avoid making FUSE requests for these reasons:
+ // 1. A FUSE request from vold puts vold at risk of hanging if the FUSE daemon is down
+ // 2. The FUSE daemon prevents requests on /mnt/user/0/emulated/<userid != 0> and a request
+ // on /storage/emulated/10 means /mnt/user/0/emulated/10
+ // TODO(b/146419093): Use lower filesystem paths that don't depend on sdcardfs
+ const std::string lowerPath = "/mnt/runtime/default/" + path.substr(9);
+ const std::string lowerAppDirRoot = "/mnt/runtime/default/" + appDirRoot.substr(9);
+
// First create the root which holds app dirs, if needed.
- int ret = PrepareDirsFromRoot(appDirRoot, "/storage/", 0771, AID_MEDIA_RW, AID_MEDIA_RW);
+ int ret = PrepareDirsFromRoot(lowerAppDirRoot, "/mnt/runtime/default/", 0771, AID_MEDIA_RW, AID_MEDIA_RW);
if (ret != 0) {
return ret;
}
// Then, create app-specific dirs with the correct UID/GID
- return PrepareDirsFromRoot(path, appDirRoot, 0770, appUid, AID_MEDIA_RW);
+ return PrepareDirsFromRoot(lowerPath, lowerAppDirRoot, 0770, appUid, AID_MEDIA_RW);
}
int VolumeManager::createObb(const std::string& sourcePath, const std::string& sourceKey,