mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
fdtdump: Port to LibMain
This commit is contained in:
parent
a35f51f0f0
commit
27e63d40f1
Notes:
sideshowbarker
2024-07-17 22:44:06 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/27e63d40f1c Pull-request: https://github.com/SerenityOS/serenity/pull/11253 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/bgianfo ✅
@ -87,7 +87,7 @@ target_link_libraries(disasm LibX86)
|
||||
target_link_libraries(dmesg LibMain)
|
||||
target_link_libraries(echo LibMain)
|
||||
target_link_libraries(expr LibRegex)
|
||||
target_link_libraries(fdtdump LibDeviceTree)
|
||||
target_link_libraries(fdtdump LibDeviceTree LibMain)
|
||||
target_link_libraries(file LibGfx LibIPC LibCompress)
|
||||
target_link_libraries(find LibMain)
|
||||
target_link_libraries(fortune LibMain)
|
||||
|
@ -7,29 +7,22 @@
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibDeviceTree/Validation.h>
|
||||
#include <serenity.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
if (pledge("stdio rpath", nullptr) < 0) {
|
||||
perror("pledge");
|
||||
return 1;
|
||||
}
|
||||
TRY(Core::System::pledge("stdio rpath"));
|
||||
|
||||
String filename;
|
||||
|
||||
Core::ArgsParser args;
|
||||
args.add_positional_argument(filename, "File to process", "file", Core::ArgsParser::Required::Yes);
|
||||
args.parse(argc, argv);
|
||||
args.parse(arguments);
|
||||
|
||||
// FIXME: Figure out how to do this sanely from stdin
|
||||
auto maybe_file = Core::MappedFile::map(filename);
|
||||
if (maybe_file.is_error()) {
|
||||
warnln("Unable to dump device tree from file {}: {}", filename, maybe_file.error());
|
||||
return 1;
|
||||
}
|
||||
auto file = maybe_file.release_value();
|
||||
auto file = TRY(Core::MappedFile::map(filename));
|
||||
|
||||
if (file->size() < sizeof(DeviceTree::FlattenedDeviceTreeHeader)) {
|
||||
warnln("Not enough data in {} to contain a device tree header!", filename);
|
||||
|
Loading…
Reference in New Issue
Block a user