mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
lsusb: Port to LibMain
This commit is contained in:
parent
097c1e5335
commit
b2e7102194
Notes:
sideshowbarker
2024-07-18 00:47:17 +09:00
Author: https://github.com/faxe1008 Commit: https://github.com/SerenityOS/serenity/commit/b2e71021940 Pull-request: https://github.com/SerenityOS/serenity/pull/11042 Reviewed-by: https://github.com/mustafaquraish ✅
@ -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)
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user