summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-04-19 01:36:39 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-04-19 01:36:39 +0000
commit252b11347895767986eb639b59571fe349937c9f (patch)
tree81d344df5c37e0f4bf86ff56f66f161d058c6dac
parentad7709e22c63d9308631d95c10cb425e38f22fdc (diff)
parentb3fe9425e19f914cc7d8083a16f316cec05cf127 (diff)
downloadvold-android14-d1-s5-release.tar.gz
Change-Id: I0668ca044470b701e2fa254b336b5d081cae654d
-rw-r--r--Utils.cpp56
1 files changed, 37 insertions, 19 deletions
diff --git a/Utils.cpp b/Utils.cpp
index bcde4d29..40a182bc 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -1771,27 +1771,45 @@ std::pair<android::base::unique_fd, std::string> OpenDirInProcfs(std::string_vie
return {std::move(fd), std::move(linkPath)};
}
+static bool IsPropertySet(const char* name, bool& value) {
+ if (base::GetProperty(name, "") == "") return false;
+
+ value = base::GetBoolProperty(name, false);
+ LOG(INFO) << "fuse-bpf is " << (value ? "enabled" : "disabled") << " because of property "
+ << name;
+ return true;
+}
+
bool IsFuseBpfEnabled() {
- bool enabled;
- std::string contents;
-
- if (base::GetProperty("ro.fuse.bpf.is_running", "") != "")
- enabled = base::GetBoolProperty("ro.fuse.bpf.is_running", false);
- else if (base::GetProperty("persist.sys.fuse.bpf.override", "") != "")
- enabled = base::GetBoolProperty("persist.sys.fuse.bpf.override", false);
- else if (base::GetProperty("ro.fuse.bpf.enabled", "") != "")
- enabled = base::GetBoolProperty("ro.fuse.bpf.enabled", false);
- else
- enabled = base::ReadFileToString("/sys/fs/fuse/features/fuse_bpf", &contents) &&
- contents == "supported\n";
-
- if (enabled) {
- base::SetProperty("ro.fuse.bpf.is_running", "true");
- return true;
- } else {
- base::SetProperty("ro.fuse.bpf.is_running", "false");
- return false;
+ // This logic is reproduced in packages/providers/MediaProvider/jni/FuseDaemon.cpp
+ // so changes made here must be reflected there
+ bool enabled = false;
+
+ if (IsPropertySet("ro.fuse.bpf.is_running", enabled)) return enabled;
+
+ if (!IsPropertySet("persist.sys.fuse.bpf.override", enabled) &&
+ !IsPropertySet("ro.fuse.bpf.enabled", enabled)) {
+ // If the kernel has fuse-bpf, /sys/fs/fuse/features/fuse_bpf will exist and have the
+ // contents 'supported\n' - see fs/fuse/inode.c in the kernel source
+ std::string contents;
+ const char* filename = "/sys/fs/fuse/features/fuse_bpf";
+ if (!base::ReadFileToString(filename, &contents)) {
+ LOG(INFO) << "fuse-bpf is disabled because " << filename << " cannot be read";
+ enabled = false;
+ } else if (contents == "supported\n") {
+ LOG(INFO) << "fuse-bpf is enabled because " << filename << " reads 'supported'";
+ enabled = true;
+ } else {
+ LOG(INFO) << "fuse-bpf is disabled because " << filename
+ << " does not read 'supported'";
+ enabled = false;
+ }
}
+
+ std::string value = enabled ? "true" : "false";
+ LOG(INFO) << "Setting ro.fuse.bpf.is_running to " << value;
+ base::SetProperty("ro.fuse.bpf.is_running", value);
+ return enabled;
}
} // namespace vold