From b6917bc8861f52755e6ecd9c407e58368f75b2cd Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Sat, 7 Jan 2023 21:03:00 +0100 Subject: [PATCH] blockdev: Use Core::System::open() instead of LibC open() --- Userland/Utilities/blockdev.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Userland/Utilities/blockdev.cpp b/Userland/Utilities/blockdev.cpp index 06fb42085d9..8e3d574f029 100644 --- a/Userland/Utilities/blockdev.cpp +++ b/Userland/Utilities/blockdev.cpp @@ -24,7 +24,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil(nullptr, nullptr)); TRY(Core::System::pledge("stdio rpath")); - char const* device = nullptr; + StringView device; bool flag_get_disk_size = false; bool flag_get_block_size = false; @@ -36,11 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(device, "Device to query", "device"); args_parser.parse(arguments); - int fd = open(device, O_RDONLY); - if (fd < 0) { - perror("open"); - return 1; - } + int fd = TRY(Core::System::open(device, O_RDONLY)); if (flag_get_disk_size) { TRY(fetch_ioctl(fd, STORAGE_DEVICE_GET_SIZE));