Merge "sort dump execution"
This commit is contained in:
commit
b21bbea2c0
@ -74,21 +74,21 @@ void endSection(int fd, const std::string §ionName, timepoint_t startTime) {
|
|||||||
void Dumpstate::dumpTextSection(int fd, const std::string §ionName) {
|
void Dumpstate::dumpTextSection(int fd, const std::string §ionName) {
|
||||||
bool dumpAll = (sectionName == kAllSections);
|
bool dumpAll = (sectionName == kAllSections);
|
||||||
std::string dumpFiles;
|
std::string dumpFiles;
|
||||||
|
struct dirent **dirent_list = NULL;
|
||||||
// Execute all or designated programs under vendor/bin/dump/
|
int num_entries = scandir("/vendor/bin/dump", &dirent_list, 0, (int (*)(const struct dirent **, const struct dirent **)) alphasort);
|
||||||
std::unique_ptr<DIR, decltype(&closedir)> dir(opendir("/vendor/bin/dump"), closedir);
|
if (!dirent_list) {
|
||||||
if (!dir) {
|
ALOGE("Unable to scan dir: /vendor/bin/dump\n");
|
||||||
ALOGE("Fail To Open Dir vendor/bin/dump/");
|
return;
|
||||||
::android::base::WriteStringToFd("Fail To Open Dir vendor/bin/dump/\n", fd);
|
} else if (num_entries <= 0) {
|
||||||
|
ALOGE("No file is found.\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dirent *entry;
|
// Execute all or designated programs under vendor/bin/dump/
|
||||||
while ((entry = readdir(dir.get())) != nullptr) {
|
for (int i = 0; i < num_entries; i++) {
|
||||||
// Skip '.', '..'
|
if (dirent_list[i]->d_name[0] == '.') {
|
||||||
if (entry->d_name[0] == '.') {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string bin(entry->d_name);
|
std::string bin(dirent_list[i]->d_name);
|
||||||
dumpFiles = dumpFiles + " " + bin;
|
dumpFiles = dumpFiles + " " + bin;
|
||||||
if (dumpAll || sectionName == bin) {
|
if (dumpAll || sectionName == bin) {
|
||||||
auto startTime = startSection(fd, bin);
|
auto startTime = startSection(fd, bin);
|
||||||
@ -111,6 +111,10 @@ void Dumpstate::dumpTextSection(int fd, const std::string §ionName) {
|
|||||||
::android::base::WriteStringToFd(dumpFiles, fd);
|
::android::base::WriteStringToFd(dumpFiles, fd);
|
||||||
::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. dump_soc) are"
|
::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. dump_soc) are"
|
||||||
"not available from the command line.\n", fd);
|
"not available from the command line.\n", fd);
|
||||||
|
while (num_entries--) {
|
||||||
|
free(dirent_list[num_entries]);
|
||||||
|
}
|
||||||
|
free(dirent_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dumpstate::dumpLogSection(int fd, int fd_bin)
|
void Dumpstate::dumpLogSection(int fd, int fd_bin)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user