Log reason for fuse-bpf being enabled/disabled
Also don't try to set ro.fuse.bpf.is_running if it's already set. Bug: 278263648 Ignore-AOSP-First: Feature is in internal Test: Examine logs with various properties set Change-Id: I9623a02c7065fa0d0c71c618d448bda0cd2a900e
This commit is contained in:
parent
ee0a2bf52e
commit
9adf86a881
1 changed files with 35 additions and 17 deletions
52
Utils.cpp
52
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)};
|
||||
}
|
||||
|
||||
bool IsFuseBpfEnabled() {
|
||||
bool enabled;
|
||||
std::string contents;
|
||||
static bool IsPropertySet(const char* name, bool& value) {
|
||||
if (base::GetProperty(name, "") == "") return false;
|
||||
|
||||
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");
|
||||
value = base::GetBoolProperty(name, false);
|
||||
LOG(INFO) << "fuse-bpf is " << (value ? "enabled" : "disabled") << " because of property "
|
||||
<< name;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IsFuseBpfEnabled() {
|
||||
// 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 {
|
||||
base::SetProperty("ro.fuse.bpf.is_running", "false");
|
||||
return false;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue