diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-19 01:39:43 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-04-19 01:39:43 +0000 |
commit | ab623c5088f8c55eaccf44ae9cf0cde7b96c44ca (patch) | |
tree | 81d344df5c37e0f4bf86ff56f66f161d058c6dac | |
parent | 991357841f38189772be3064396b08ac81c65b76 (diff) | |
parent | 9adf86a88189af16e04e8b439bd2e5078acadb4d (diff) | |
download | vold-android14-s2-release.tar.gz |
Snap for 9966400 from 9adf86a88189af16e04e8b439bd2e5078acadb4d to udc-releaseandroid-vts-14.0_r4android-vts-14.0_r3android-vts-14.0_r2android-vts-14.0_r1android-security-14.0.0_r9android-security-14.0.0_r8android-security-14.0.0_r7android-security-14.0.0_r6android-security-14.0.0_r5android-security-14.0.0_r4android-security-14.0.0_r3android-security-14.0.0_r2android-security-14.0.0_r10android-security-14.0.0_r1android-platform-14.0.0_r9android-platform-14.0.0_r8android-platform-14.0.0_r7android-platform-14.0.0_r6android-platform-14.0.0_r5android-platform-14.0.0_r4android-platform-14.0.0_r3android-platform-14.0.0_r2android-platform-14.0.0_r1android-cts-14.0_r4android-cts-14.0_r3android-cts-14.0_r2android-cts-14.0_r1android-14.0.0_r28android-14.0.0_r2android-14.0.0_r15android-14.0.0_r14android-14.0.0_r13android-14.0.0_r1android14-tests-releaseandroid14-security-releaseandroid14-s2-releaseandroid14-s1-releaseandroid14-releaseandroid14-platform-release
Change-Id: I06a38c24ed5950ef69cc392c71fc4f02a2714278
-rw-r--r-- | Utils.cpp | 56 |
1 files changed, 37 insertions, 19 deletions
@@ -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 |