allow dumpstate to execute files under vendor/bin/dump

Bug: 240530709
Test: adb bugreport has the same result
Change-Id: I76a82ef6402d6bfb53d21d63c354d934ffb06c57
This commit is contained in:
Adam Shih 2022-09-15 14:09:36 +08:00 committed by TreeHugger Robot
parent 4abe8cc283
commit 02c91097f8
3 changed files with 19 additions and 8 deletions

View file

@ -238,7 +238,6 @@ Dumpstate::Dumpstate()
{ "aoc", [this](int fd) { dumpAoCSection(fd); } },
{ "ramdump", [this](int fd) { dumpRamdumpSection(fd); } },
{ "misc", [this](int fd) { dumpMiscSection(fd); } },
{ "dump", [this](int fd) { dumpSection(fd); } },
{ "trusty", [this](int fd) { dumpTrustySection(fd); } },
{ "led", [this](int fd) { dumpLEDSection(fd); } },
},
@ -268,6 +267,24 @@ void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
}
}
// Execute all programs under vendor/bin/dump/
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir);
if (!dir) {
ALOGE("Fail To Open Dir vendor/bin/dump/");
} else {
dirent *entry;
while ((entry = readdir(dir.get())) != nullptr) {
// Skip '.', '..'
if (entry->d_name[0] == '.') {
continue;
}
std::string bin(entry->d_name);
auto startTime = startSection(fd, "/vendor/bin/dump/"+bin);
RunCommandToFd(fd, "/vendor/bin/dump/"+bin, {"/vendor/bin/dump/"+bin});
endSection(fd, "/vendor/bin/dump/"+bin, startTime);
}
}
if (dumpAll) {
return;
}
@ -1126,11 +1143,6 @@ void Dumpstate::dumpMiscSection(int fd) {
DumpFileToFd(fd, "VENDOR PROC DUMP", "/proc/vendor_sched/dump_task");
}
// Dump scripts under vendor/bin/dump
void Dumpstate::dumpSection(int fd) {
RunCommandToFd(fd, "dump", {"/vendor/bin/dump/dump_gsc.sh"});
}
void Dumpstate::dumpTrustySection(int fd) {
RunCommandToFd(fd, "Trusty TEE0 Logs", {"/vendor/bin/sh", "-c", "cat /dev/trusty-log0"}, CommandOptions::WithTimeout(1).Build());
}