Skip to content

Commit

Permalink
Applications: Use new global variables at /sys/kernel/ directory
Browse files Browse the repository at this point in the history
  • Loading branch information
supercomputer7 authored and ADKaster committed Oct 25, 2022
1 parent 6e50857 commit 5dfb2b1
Show file tree
Hide file tree
Showing 28 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Userland/Applications/3DFileViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

TRY(Core::System::pledge("stdio thread recvfd sendfd rpath unix prot_exec"));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/home/anon/Documents/3D Models", "r"));
TRY(Core::System::unveil("/res", "r"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Browser/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil(webdriver_ipc_path.view(), "rw"sv));
}

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/image", "rw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Help/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));
auto app = TRY(GUI::Application::try_create(arguments));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/usr/share/man", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/HexEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return GUI::Window::CloseRequestDecision::StayOpen;
};

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ KeyboardSettingsWidget::KeyboardSettingsWidget()
{
load_from_gml(keyboard_widget_gml);

auto proc_keymap = Core::File::construct("/proc/keymap");
auto proc_keymap = Core::File::construct("/sys/kernel/keymap");
if (!proc_keymap->open(Core::OpenMode::ReadOnly))
VERIFY_NOT_REACHED();

Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/KeyboardSettings/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio rpath recvfd sendfd proc exec"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin/keymap", "x"));
TRY(Core::System::unveil("/proc/keymap", "r"));
TRY(Core::System::unveil("/sys/kernel/keymap", "r"));
TRY(Core::System::unveil("/etc/Keyboard.ini", "r"));
TRY(Core::System::unveil(nullptr, nullptr));

Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Magnifier/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio cpath rpath recvfd sendfd unix"));
auto app = TRY(GUI::Application::try_create(arguments));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Mail/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

Config::pledge_domain("Mail");

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/etc", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ NetworkSettingsWidget::NetworkSettingsWidget()

auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors();

auto proc_net_adapters_file = Core::Stream::File::open("/proc/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto proc_net_adapters_file = Core::Stream::File::open("/sys/kernel/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto data = proc_net_adapters_file->read_all().release_value_but_fixme_should_propagate_errors();
JsonParser parser(data);
JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors();
Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/NetworkSettings/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)

TRY(Core::System::unveil("/bin/NetworkServer", "x"));
TRY(Core::System::unveil("/etc/Network.ini", "rwc"));
TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/proc/net/adapters", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/sys/kernel/net/adapters", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/clipboard", "rw"));
TRY(Core::System::unveil("/tmp/portal/window", "rw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/PDFViewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

TRY(Core::System::pledge("stdio recvfd sendfd rpath unix"));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/PixelPaint/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(image_file, "Image file to open", "path", Core::ArgsParser::Required::No);
args_parser.parse(arguments);

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/clipboard", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/SpaceAnalyzer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct MountInfo {
static void fill_mounts(Vector<MountInfo>& output)
{
// Output info about currently mounted filesystems.
auto file = Core::File::construct("/proc/df");
auto file = Core::File::construct("/sys/kernel/df");
if (!file->open(Core::OpenMode::ReadOnly)) {
warnln("Failed to open {}: {}", file->name(), file->error_string());
return;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Spreadsheet/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
// For writing temporary files when exporting.
TRY(Core::System::unveil("/tmp", "crw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static inline u64 page_count_to_bytes(size_t count)

void MemoryStatsWidget::refresh()
{
auto proc_memstat = Core::File::construct("/proc/memstat");
auto proc_memstat = Core::File::construct("/sys/kernel/memstat");
if (!proc_memstat->open(Core::OpenMode::ReadOnly))
VERIFY_NOT_REACHED();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
net_adapters_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight);
net_adapters_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
m_adapter_model = GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields));
m_adapter_model = GUI::JsonArrayModel::create("/sys/kernel/net/adapters", move(net_adapters_fields));
m_adapter_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_adapter_model)));

auto& tcp_sockets_group_box = add<GUI::GroupBox>("TCP Sockets"sv);
Expand All @@ -90,7 +90,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
net_tcp_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight);
net_tcp_fields.empend("bytes_in", "Bytes In", Gfx::TextAlignment::CenterRight);
net_tcp_fields.empend("bytes_out", "Bytes Out", Gfx::TextAlignment::CenterRight);
m_tcp_socket_model = GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields));
m_tcp_socket_model = GUI::JsonArrayModel::create("/sys/kernel/net/tcp", move(net_tcp_fields));
m_tcp_socket_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_tcp_socket_model)));

auto& udp_sockets_group_box = add<GUI::GroupBox>("UDP Sockets"sv);
Expand All @@ -104,7 +104,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget()
net_udp_fields.empend("peer_port", "Port", Gfx::TextAlignment::CenterRight);
net_udp_fields.empend("local_address", "Local", Gfx::TextAlignment::CenterLeft);
net_udp_fields.empend("local_port", "Port", Gfx::TextAlignment::CenterRight);
m_udp_socket_model = GUI::JsonArrayModel::create("/proc/net/udp", move(net_udp_fields));
m_udp_socket_model = GUI::JsonArrayModel::create("/sys/kernel/net/udp", move(net_udp_fields));
m_udp_socket_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_udp_socket_model)));

m_update_timer = add<Core::Timer>(
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/SystemMonitor/ProcessModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ProcessModel::ProcessModel()
VERIFY(!s_the);
s_the = this;

auto file = Core::File::construct("/proc/cpuinfo");
auto file = Core::File::construct("/sys/kernel/cpuinfo");
if (file->open(Core::OpenMode::ReadOnly)) {
auto buffer = file->read_all();
auto json = JsonValue::from_string({ buffer });
Expand Down
3 changes: 2 additions & 1 deletion Userland/Applications/SystemMonitor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class StorageTabWidget final : public GUI::LazyWidget {
df_fields.empend("total_inode_count", "Total inodes", Gfx::TextAlignment::CenterRight);
df_fields.empend("block_size", "Block size", Gfx::TextAlignment::CenterRight);

fs_table_view.set_model(MUST(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields)))));
fs_table_view.set_model(MUST(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/sys/kernel/df", move(df_fields)))));

fs_table_view.set_column_painting_delegate(3, make<ProgressbarPaintingDelegate>());

Expand Down Expand Up @@ -243,6 +243,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/etc/passwd", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/proc", "r"));
TRY(Core::System::unveil("/sys/kernel", "r"));
TRY(Core::System::unveil("/dev", "r"));
TRY(Core::System::unveil("/bin", "r"));
TRY(Core::System::unveil("/usr/lib", "r"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Terminal/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return GUI::Window::CloseRequestDecision::StayOpen;
};

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin", "r"));
TRY(Core::System::unveil("/proc", "r"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/TextEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
parser.add_positional_argument(file_to_edit, "File to edit, with optional starting line and column number", "file[:line[:column]]", Core::ArgsParser::Required::No);
parser.parse(arguments);

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/launch", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/ThemeEditor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
path = Core::File::absolute_path(file_to_edit);

TRY(Core::System::pledge("stdio recvfd sendfd thread rpath unix"));
TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/Welcome/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

Config::pledge_domain("SystemServer");

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/webcontent", "rw"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Demos/CatDog/CatDog.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class CatDog final : public GUI::Widget

CatDog()
: m_temp_pos { 0, 0 }
, m_proc_all(MUST(Core::File::open("/proc/all", Core::OpenMode::ReadOnly)))
, m_proc_all(MUST(Core::File::open("/sys/kernel/processes", Core::OpenMode::ReadOnly)))
{
set_image_by_main_state();
}
Expand Down
4 changes: 2 additions & 2 deletions Userland/Demos/CatDog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

TRY(Core::System::pledge("stdio recvfd sendfd rpath"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/proc/all", "r"));
// FIXME: For some reason, this is needed in the /proc/all shenanigans.
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
// FIXME: For some reason, this is needed in the /sys/kernel/processes shenanigans.
TRY(Core::System::unveil("/etc/passwd", "r"));
TRY(Core::System::unveil(nullptr, nullptr));

Expand Down
2 changes: 1 addition & 1 deletion Userland/Demos/Eyes/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)

auto app = TRY(GUI::Application::try_create(arguments));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/launch", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Expand Down
2 changes: 1 addition & 1 deletion Userland/Demos/WidgetGallery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio recvfd sendfd rpath unix thread"));
auto app = TRY(GUI::Application::try_create(arguments, Core::EventLoop::MakeInspectable::Yes));

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/filesystemaccess", "rw"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r"));
Expand Down
2 changes: 1 addition & 1 deletion Userland/DevTools/Inspector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin", "r"));
TRY(Core::System::unveil("/tmp", "rwc"));
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));

Expand Down
2 changes: 1 addition & 1 deletion Userland/Games/Chess/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = TRY(GUI::Window::try_create());
auto widget = TRY(window->try_set_main_widget<ChessWidget>());

TRY(Core::System::unveil("/proc/all", "r"));
TRY(Core::System::unveil("/sys/kernel/processes", "r"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/bin/ChessEngine", "x"));
TRY(Core::System::unveil("/tmp/session/%sid/portal/launch", "rw"));
Expand Down

0 comments on commit 5dfb2b1

Please sign in to comment.