Browse Source

SystemMonitor+LibCore: Show process pledges in SystemMonitor :^)

Andreas Kling 5 years ago
parent
commit
ec1ae37f69

+ 9 - 0
Applications/SystemMonitor/ProcessModel.cpp

@@ -93,6 +93,8 @@ String ProcessModel::column_name(int column) const
         return "File In";
     case Column::FileWriteBytes:
         return "File Out";
+    case Column::Pledge:
+        return "Pledge";
     default:
         ASSERT_NOT_REACHED();
     }
@@ -151,6 +153,8 @@ GModel::ColumnMetadata ProcessModel::column_metadata(int column) const
         return { 60, TextAlignment::CenterRight };
     case Column::IPv4SocketWriteBytes:
         return { 60, TextAlignment::CenterRight };
+    case Column::Pledge:
+        return { 60, TextAlignment::CenterLeft };
     default:
         ASSERT_NOT_REACHED();
     }
@@ -220,6 +224,8 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
             return thread.current_state.file_read_bytes;
         case Column::FileWriteBytes:
             return thread.current_state.file_write_bytes;
+        case Column::Pledge:
+            return thread.current_state.pledge;
         }
         ASSERT_NOT_REACHED();
         return {};
@@ -285,6 +291,8 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
             return thread.current_state.file_read_bytes;
         case Column::FileWriteBytes:
             return thread.current_state.file_write_bytes;
+        case Column::Pledge:
+            return thread.current_state.pledge;
         }
     }
 
@@ -306,6 +314,7 @@ void ProcessModel::update()
             ThreadState state;
             state.pid = it.value.pid;
             state.user = it.value.username;
+            state.pledge = it.value.pledge;
             state.syscall_count = thread.syscall_count;
             state.inode_faults = thread.inode_faults;
             state.zero_faults = thread.zero_faults;

+ 2 - 0
Applications/SystemMonitor/ProcessModel.h

@@ -35,6 +35,7 @@ public:
         CleanInode,
         PurgeableVolatile,
         PurgeableNonvolatile,
+        Pledge,
         Syscalls,
         InodeFaults,
         ZeroFaults,
@@ -72,6 +73,7 @@ private:
         String name;
         String state;
         String user;
+        String pledge;
         u32 priority;
         u32 effective_priority;
         size_t amount_virtual;

+ 1 - 0
Libraries/LibCore/CProcessStatisticsReader.cpp

@@ -35,6 +35,7 @@ HashMap<pid_t, CProcessStatistics> CProcessStatisticsReader::get_all()
         process.nfds = process_object.get("nfds").to_u32();
         process.name = process_object.get("name").to_string();
         process.tty = process_object.get("tty").to_string();
+        process.pledge = process_object.get("pledge").to_string();
         process.amount_virtual = process_object.get("amount_virtual").to_u32();
         process.amount_resident = process_object.get("amount_resident").to_u32();
         process.amount_shared = process_object.get("amount_shared").to_u32();

+ 1 - 0
Libraries/LibCore/CProcessStatisticsReader.h

@@ -37,6 +37,7 @@ struct CProcessStatistics {
     unsigned nfds;
     String name;
     String tty;
+    String pledge;
     size_t amount_virtual;
     size_t amount_resident;
     size_t amount_shared;