mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-13 09:50:36 +00:00
Utilities: Use new global variables at /sys/kernel/ directory
This commit is contained in:
parent
35c98a031a
commit
9d1ba0e6ad
Notes:
sideshowbarker
2024-07-17 05:06:11 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/9d1ba0e6ad Pull-request: https://github.com/SerenityOS/serenity/pull/15593 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/kleinesfilmroellchen ✅
21 changed files with 30 additions and 29 deletions
|
@ -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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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 }));
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue