1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

lspci: Use pledge() and unveil()

This commit is contained in:
Brian Gianforcaro 2020-01-23 00:42:50 -08:00 committed by Andreas Kling
parent d66bbc21ce
commit e3e22cd42e

View file

@ -36,6 +36,23 @@ int main(int argc, char** argv)
UNUSED_PARAM(argc);
UNUSED_PARAM(argv);
if (pledge("stdio rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/res/pci.ids", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil("/proc/pci", "r") < 0) {
perror("unveil");
return 1;
}
unveil(nullptr, nullptr);
auto db = PCIDB::Database::open();
if (!db)
fprintf(stderr, "Couldn't open PCI ID database\n");
@ -46,6 +63,11 @@ int main(int argc, char** argv)
return 1;
}
if (pledge("stdio", nullptr) < 0) {
perror("pledge");
return 1;
}
auto file_contents = proc_pci->read_all();
auto json = JsonValue::from_string(file_contents).as_array();
json.for_each([db](auto& value) {