Merge "ext4_utils: skip symbolic links in basefs file" into oc-mr1-dev
diff --git a/ext4_utils/ext4_crypt_init_extensions.cpp b/ext4_utils/ext4_crypt_init_extensions.cpp
index 2bf8801..35a1c21 100644
--- a/ext4_utils/ext4_crypt_init_extensions.cpp
+++ b/ext4_utils/ext4_crypt_init_extensions.cpp
@@ -41,6 +41,8 @@
static const std::string arbitrary_sequence_number = "42";
static const int vold_command_timeout_ms = 60 * 1000;
+static int set_system_de_policy_on(char const* dir);
+
int e4crypt_install_keyring()
{
key_serial_t device_keyring = add_key("keyring", "e4crypt", 0, 0,
@@ -58,11 +60,22 @@
int e4crypt_set_directory_policy(const char* dir)
{
+ if (!dir || strncmp(dir, "/data/", 6)) {
+ return 0;
+ }
+
+ // Special-case /data/media/obb per b/64566063
+ if (strcmp(dir, "/data/media/obb") == 0) {
+ // Try to set policy on this directory, but if it is non-empty this may fail.
+ set_system_de_policy_on(dir);
+ return 0;
+ }
+
// Only set policy on first level /data directories
// To make this less restrictive, consider using a policy file.
// However this is overkill for as long as the policy is simply
// to apply a global policy to all /data folders created via makedir
- if (!dir || strncmp(dir, "/data/", 6) || strchr(dir + 6, '/')) {
+ if (strchr(dir + 6, '/')) {
return 0;
}
@@ -83,7 +96,10 @@
return 0;
}
}
+ return set_system_de_policy_on(dir);
+}
+static int set_system_de_policy_on(char const* dir) {
std::string ref_filename = std::string("/data") + e4crypt_key_ref;
std::string policy;
if (!android::base::ReadFileToString(ref_filename, &policy)) {
diff --git a/simpleperf/event_selection_set.cpp b/simpleperf/event_selection_set.cpp
index 86f57b9..7458572 100644
--- a/simpleperf/event_selection_set.cpp
+++ b/simpleperf/event_selection_set.cpp
@@ -342,7 +342,7 @@
EventFd* group_fd = nullptr;
for (auto& selection : group) {
std::unique_ptr<EventFd> event_fd =
- EventFd::OpenEventFile(selection.event_attr, tid, cpu, group_fd);
+ EventFd::OpenEventFile(selection.event_attr, tid, cpu, group_fd, false);
if (event_fd != nullptr) {
LOG(VERBOSE) << "OpenEventFile for " << event_fd->Name();
event_fds.push_back(std::move(event_fd));
@@ -402,24 +402,25 @@
}
} else {
for (const auto& pair : process_map) {
+ size_t success_count = 0;
+ std::string failed_event_type;
for (const auto& tid : pair.second) {
- size_t success_cpu_count = 0;
- std::string failed_event_type;
for (const auto& cpu : cpus) {
if (OpenEventFilesOnGroup(group, tid, cpu, &failed_event_type)) {
- success_cpu_count++;
+ success_count++;
}
}
- // As the online cpus can be enabled or disabled at runtime, we may not
- // open event file for all cpus successfully. But we should open at
- // least one cpu successfully.
- if (success_cpu_count == 0) {
- PLOG(ERROR) << "failed to open perf event file for event_type "
- << failed_event_type << " for "
- << (tid == -1 ? "all threads" : "thread " + std::to_string(tid))
- << " on all cpus";
- return false;
- }
+ }
+ // We can't guarantee to open perf event file successfully for each thread on each cpu.
+ // Because threads may exit between PrepareThreads() and OpenEventFilesOnGroup(), and
+ // cpus may be offlined between GetOnlineCpus() and OpenEventFilesOnGroup().
+ // So we only check that we can at least monitor one thread for each process.
+ if (success_count == 0) {
+ PLOG(ERROR) << "failed to open perf event file for event_type "
+ << failed_event_type << " for "
+ << (pair.first == -1 ? "all threads"
+ : "threads in process " + std::to_string(pair.first));
+ return false;
}
}
}