瀏覽代碼

Utilities: Use new global variables at /sys/kernel/ directory

Liav A 2 年之前
父節點
當前提交
9d1ba0e6ad

+ 1 - 1
Userland/Utilities/aplay.cpp

@@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     args_parser.add_option(show_sample_progress, "Show playback progress in samples", "sample-progress", 's');
     args_parser.parse(arguments);
 
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/tmp/session/%sid/portal/audio", "rw"));
     TRY(Core::System::unveil(Core::File::absolute_path(path), "r"sv));
     TRY(Core::System::unveil(nullptr, nullptr));

+ 2 - 2
Userland/Utilities/arp.cpp

@@ -28,7 +28,7 @@
 ErrorOr<int> serenity_main(Main::Arguments arguments)
 {
     TRY(Core::System::pledge("stdio rpath tty inet unix"));
-    TRY(Core::System::unveil("/proc/net/arp", "r"));
+    TRY(Core::System::unveil("/sys/kernel/net/arp", "r"));
     TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
@@ -89,7 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     outln();
 
     if (!flag_set && !flag_delete) {
-        auto file = Core::File::construct("/proc/net/arp");
+        auto file = Core::File::construct("/sys/kernel/net/arp");
         if (!file->open(Core::OpenMode::ReadOnly)) {
             warnln("Failed to open {}: {}", file->name(), file->error_string());
             return 1;

+ 1 - 1
Userland/Utilities/df.cpp

@@ -33,7 +33,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     args_parser.add_option(flag_human_readable, "Print human-readable sizes", "human-readable", 'h');
     args_parser.parse(arguments);
 
-    auto file = TRY(Core::File::open("/proc/df", Core::OpenMode::ReadOnly));
+    auto file = TRY(Core::File::open("/sys/kernel/df", Core::OpenMode::ReadOnly));
 
     if (flag_human_readable) {
         outln("Filesystem      Size        Used    Available   Mount point");

+ 2 - 2
Userland/Utilities/dmesg.cpp

@@ -11,10 +11,10 @@
 ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio rpath"));
-    TRY(Core::System::unveil("/proc/dmesg", "r"));
+    TRY(Core::System::unveil("/sys/kernel/dmesg", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
-    auto file = TRY(Core::File::open("/proc/dmesg", Core::OpenMode::ReadOnly));
+    auto file = TRY(Core::File::open("/sys/kernel/dmesg", Core::OpenMode::ReadOnly));
     auto buffer = file->read_all();
     out("{}", StringView { buffer });
     return 0;

+ 1 - 1
Userland/Utilities/ifconfig.cpp

@@ -37,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     args_parser.parse(arguments);
 
     if (value_ipv4.is_empty() && value_adapter.is_empty() && value_mask.is_empty()) {
-        auto file = TRY(Core::File::open("/proc/net/adapters", Core::OpenMode::ReadOnly));
+        auto file = TRY(Core::File::open("/sys/kernel/net/adapters", Core::OpenMode::ReadOnly));
         auto json = TRY(JsonValue::from_string(file->read_all()));
 
         json.as_array().for_each([](auto& value) {

+ 1 - 1
Userland/Utilities/logout.cpp

@@ -12,7 +12,7 @@
 ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio proc rpath"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 2 - 2
Userland/Utilities/lscpu.cpp

@@ -56,10 +56,10 @@ ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio rpath"));
 
-    TRY(Core::System::unveil("/proc/cpuinfo", "r"));
+    TRY(Core::System::unveil("/sys/kernel/cpuinfo", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
-    auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly));
+    auto file = TRY(Core::File::open("/sys/kernel/cpuinfo", Core::OpenMode::ReadOnly));
     auto json = TRY(JsonValue::from_string(file->read_all()));
     auto& array = json.as_array();
 

+ 2 - 2
Userland/Utilities/lsirq.cpp

@@ -13,10 +13,10 @@
 ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio rpath"));
-    TRY(Core::System::unveil("/proc/interrupts", "r"));
+    TRY(Core::System::unveil("/sys/kernel/interrupts", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
-    auto proc_interrupts = TRY(Core::File::open("/proc/interrupts", Core::OpenMode::ReadOnly));
+    auto proc_interrupts = TRY(Core::File::open("/sys/kernel/interrupts", Core::OpenMode::ReadOnly));
 
     TRY(Core::System::pledge("stdio"));
 

+ 1 - 0
Userland/Utilities/lsof.cpp

@@ -105,6 +105,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
 
     TRY(Core::System::unveil("/proc", "r"));
     // needed by ProcessStatisticsReader::get_all()
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 1 - 1
Userland/Utilities/mount.cpp

@@ -153,7 +153,7 @@ static ErrorOr<void> mount_all()
 static ErrorOr<void> print_mounts()
 {
     // Output info about currently mounted filesystems.
-    auto df = TRY(Core::File::open("/proc/df", Core::OpenMode::ReadOnly));
+    auto df = TRY(Core::File::open("/sys/kernel/df", Core::OpenMode::ReadOnly));
 
     auto content = df->read_all();
     auto json = TRY(JsonValue::from_string(content));

+ 4 - 4
Userland/Utilities/netstat.cpp

@@ -44,8 +44,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     args_parser.add_option(flag_wide, "Do not truncate IP addresses by printing out the whole symbolic host", "wide", 'W');
     args_parser.parse(arguments);
 
-    TRY(Core::System::unveil("/proc/net", "r"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/net", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil("/etc/services", "r"));
     TRY(Core::System::unveil("/tmp/portal/lookup", "rw"));
@@ -154,7 +154,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     }
 
     if (!has_protocol_flag || flag_tcp) {
-        auto file = Core::File::construct("/proc/net/tcp");
+        auto file = Core::File::construct("/sys/kernel/net/tcp");
         if (!file->open(Core::OpenMode::ReadOnly)) {
             warnln("Error: {}", file->error_string());
             return 1;
@@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     }
 
     if (!has_protocol_flag || flag_udp) {
-        auto file = TRY(Core::File::open("/proc/net/udp", Core::OpenMode::ReadOnly));
+        auto file = TRY(Core::File::open("/sys/kernel/net/udp", Core::OpenMode::ReadOnly));
         auto file_contents = file->read_all();
         auto json = TRY(JsonValue::from_string(file_contents));
 

+ 1 - 1
Userland/Utilities/nproc.cpp

@@ -12,7 +12,7 @@
 ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio rpath"));
-    auto file = TRY(Core::File::open("/proc/cpuinfo", Core::OpenMode::ReadOnly));
+    auto file = TRY(Core::File::open("/sys/kernel/cpuinfo", Core::OpenMode::ReadOnly));
 
     auto buffer = file->read_all();
     auto json = TRY(JsonValue::from_string({ buffer }));

+ 1 - 1
Userland/Utilities/pgrep.cpp

@@ -15,7 +15,7 @@
 ErrorOr<int> serenity_main(Main::Arguments args)
 {
     TRY(Core::System::pledge("stdio rpath"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 1 - 1
Userland/Utilities/pidof.cpp

@@ -43,7 +43,7 @@ static ErrorOr<int> pid_of(String const& process_name, bool single_shot, bool om
 ErrorOr<int> serenity_main(Main::Arguments args)
 {
     TRY(Core::System::pledge("stdio rpath"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 1 - 1
Userland/Utilities/pkill.cpp

@@ -18,7 +18,7 @@
 ErrorOr<int> serenity_main(Main::Arguments args)
 {
     TRY(Core::System::pledge("stdio proc rpath"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 1 - 1
Userland/Utilities/profile.cpp

@@ -28,7 +28,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     bool seen_event_type_arg = false;
 
     args_parser.add_option(pid_argument, "Target PID", nullptr, 'p', "PID");
-    args_parser.add_option(all_processes, "Profile all processes (super-user only), result at /proc/profile", nullptr, 'a');
+    args_parser.add_option(all_processes, "Profile all processes (super-user only), result at /sys/kernel/profile", nullptr, 'a');
     args_parser.add_option(enable, "Enable", nullptr, 'e');
     args_parser.add_option(disable, "Disable", nullptr, 'd');
     args_parser.add_option(free, "Free the profiling buffer for the associated process(es).", nullptr, 'f');

+ 1 - 1
Userland/Utilities/ps.cpp

@@ -41,7 +41,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     auto this_pseudo_tty_name = TRY(determine_tty_pseudo_name());
 
     TRY(Core::System::pledge("stdio rpath"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 

+ 2 - 2
Userland/Utilities/route.cpp

@@ -25,7 +25,7 @@
 ErrorOr<int> serenity_main(Main::Arguments arguments)
 {
     TRY(Core::System::pledge("stdio rpath inet"));
-    TRY(Core::System::unveil("/proc/net", "r"));
+    TRY(Core::System::unveil("/sys/kernel/net", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
     StringView modify_action;
@@ -89,7 +89,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
     };
 
     if (modify_action.is_empty()) {
-        auto file = TRY(Core::File::open("/proc/net/route", Core::OpenMode::ReadOnly));
+        auto file = TRY(Core::File::open("/sys/kernel/net/route", Core::OpenMode::ReadOnly));
         auto file_contents = file->read_all();
         auto json = TRY(JsonValue::from_string(file_contents));
 

+ 1 - 1
Userland/Utilities/top.cpp

@@ -201,7 +201,7 @@ static void enable_nonblocking_stdin()
 ErrorOr<int> serenity_main(Main::Arguments arguments)
 {
     TRY(Core::System::pledge("stdio rpath tty sigaction"));
-    TRY(Core::System::unveil("/proc/all", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil("/etc/passwd", "r"));
     unveil(nullptr, nullptr);
 

+ 2 - 2
Userland/Utilities/uptime.cpp

@@ -14,9 +14,9 @@ ErrorOr<int> serenity_main(Main::Arguments)
 {
     TRY(Core::System::pledge("stdio rpath"));
 
-    FILE* fp = fopen("/proc/uptime", "r");
+    FILE* fp = fopen("/sys/kernel/uptime", "r");
     if (!fp) {
-        perror("fopen(/proc/uptime)");
+        perror("fopen(/sys/kernel/uptime)");
         return 1;
     }
 

+ 1 - 1
Userland/Utilities/w.cpp

@@ -22,7 +22,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
     TRY(Core::System::unveil("/etc/passwd", "r"));
     TRY(Core::System::unveil("/etc/timezone", "r"));
     TRY(Core::System::unveil("/var/run/utmp", "r"));
-    TRY(Core::System::unveil("/proc", "r"));
+    TRY(Core::System::unveil("/sys/kernel/processes", "r"));
     TRY(Core::System::unveil(nullptr, nullptr));
 
     auto file = TRY(Core::File::open("/var/run/utmp", Core::OpenMode::ReadOnly));