mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:07:35 +00:00
lspci: Use pledge() and unveil()
This commit is contained in:
parent
d66bbc21ce
commit
e3e22cd42e
1 changed files with 22 additions and 0 deletions
|
@ -36,6 +36,23 @@ int main(int argc, char** argv)
|
||||||
UNUSED_PARAM(argc);
|
UNUSED_PARAM(argc);
|
||||||
UNUSED_PARAM(argv);
|
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();
|
auto db = PCIDB::Database::open();
|
||||||
if (!db)
|
if (!db)
|
||||||
fprintf(stderr, "Couldn't open PCI ID database\n");
|
fprintf(stderr, "Couldn't open PCI ID database\n");
|
||||||
|
@ -46,6 +63,11 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pledge("stdio", nullptr) < 0) {
|
||||||
|
perror("pledge");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
auto file_contents = proc_pci->read_all();
|
auto file_contents = proc_pci->read_all();
|
||||||
auto json = JsonValue::from_string(file_contents).as_array();
|
auto json = JsonValue::from_string(file_contents).as_array();
|
||||||
json.for_each([db](auto& value) {
|
json.for_each([db](auto& value) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue