summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2022-10-02 18:17:24 -0600
committerAndreas Kling <kling@serenityos.org>2022-10-03 11:11:29 +0200
commit76c67b7ae958897c7485247306dc24d3c7335e66 (patch)
treeb53f1a191c4325b8e138158ec0fa49f6e809be58 /Userland/Libraries
parent71728f3ea6da0ea656b9d73889e04def17f51aa3 (diff)
downloadserenity-76c67b7ae958897c7485247306dc24d3c7335e66.zip
LibCore: Make usernames optional in ProcessStatisticsReader
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibCore/ProcessStatisticsReader.cpp10
-rw-r--r--Userland/Libraries/LibCore/ProcessStatisticsReader.h4
2 files changed, 8 insertions, 6 deletions
diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
index 979c1bc3f9..ccf136e7c5 100644
--- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
+++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp
@@ -16,7 +16,7 @@ namespace Core {
HashMap<uid_t, String> ProcessStatisticsReader::s_usernames;
-Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::File>& proc_all_file)
+Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::File>& proc_all_file, bool include_usernames)
{
if (proc_all_file) {
if (!proc_all_file->seek(0, Core::SeekMode::SetPosition)) {
@@ -93,7 +93,9 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
});
// and synthetic data last
- process.username = username_from_uid(process.uid);
+ if (include_usernames) {
+ process.username = username_from_uid(process.uid);
+ }
all_processes_statistics.processes.append(move(process));
});
@@ -102,10 +104,10 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
return all_processes_statistics;
}
-Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all()
+Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(bool include_usernames)
{
RefPtr<Core::File> proc_all_file;
- return get_all(proc_all_file);
+ return get_all(proc_all_file, include_usernames);
}
String ProcessStatisticsReader::username_from_uid(uid_t uid)
diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.h b/Userland/Libraries/LibCore/ProcessStatisticsReader.h
index 19d541a948..7edbdea024 100644
--- a/Userland/Libraries/LibCore/ProcessStatisticsReader.h
+++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.h
@@ -72,8 +72,8 @@ struct AllProcessesStatistics {
class ProcessStatisticsReader {
public:
- static Optional<AllProcessesStatistics> get_all(RefPtr<Core::File>&);
- static Optional<AllProcessesStatistics> get_all();
+ static Optional<AllProcessesStatistics> get_all(RefPtr<Core::File>&, bool include_usernames = true);
+ static Optional<AllProcessesStatistics> get_all(bool include_usernames = true);
private:
static String username_from_uid(uid_t);