lsusb: Port to LibMain

This commit is contained in:
faxe1008 2021-11-23 17:17:26 +01:00 committed by Andreas Kling
parent 097c1e5335
commit b2e7102194
Notes: sideshowbarker 2024-07-18 00:47:17 +09:00
2 changed files with 9 additions and 22 deletions

View File

@ -77,7 +77,7 @@ target_link_libraries(id LibMain)
target_link_libraries(js LibJS LibLine LibMain)
target_link_libraries(keymap LibKeyboard LibMain)
target_link_libraries(lspci LibPCIDB)
target_link_libraries(lsusb LibUSBDB)
target_link_libraries(lsusb LibUSBDB LibMain)
target_link_libraries(man LibMarkdown)
target_link_libraries(markdown-check LibMarkdown)
target_link_libraries(matroska LibVideo)

View File

@ -12,35 +12,22 @@
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
#include <LibUSBDB/Database.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, char** argv)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
if (pledge("stdio rpath", nullptr) < 0) {
perror("pledge");
return 1;
}
if (unveil("/sys/bus/usb", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil("/res/usb.ids", "r") < 0) {
perror("unveil");
return 1;
}
if (unveil(nullptr, nullptr) < 0) {
perror("unveil");
return 1;
}
TRY(Core::System::pledge("stdio rpath", nullptr));
TRY(Core::System::unveil("/sys/bus/usb", "r"));
TRY(Core::System::unveil("/res/usb.ids", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
Core::ArgsParser args;
args.set_general_help("List USB devices.");
args.parse(argc, argv);
args.parse(arguments);
Core::DirIterator usb_devices("/sys/bus/usb", Core::DirIterator::SkipDots);