1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

blockdev: Let fetch_ioctl() return ErrorOr<void>

This commit is contained in:
Kenneth Myhra 2023-01-07 21:02:53 +01:00 committed by Sam Atkins
parent 66a68a9523
commit a7dafacced

View file

@ -8,17 +8,14 @@
#include <LibCore/System.h> #include <LibCore/System.h>
#include <LibMain/Main.h> #include <LibMain/Main.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
static void fetch_ioctl(int fd, int request) static ErrorOr<void> fetch_ioctl(int fd, int request)
{ {
u64 value; u64 value;
if (ioctl(fd, request, &value) < 0) { TRY(Core::System::ioctl(fd, request, &value));
perror("ioctl");
exit(1);
}
outln("{}", value); outln("{}", value);
return {};
} }
ErrorOr<int> serenity_main(Main::Arguments arguments) ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -46,10 +43,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} }
if (flag_get_disk_size) { if (flag_get_disk_size) {
fetch_ioctl(fd, STORAGE_DEVICE_GET_SIZE); TRY(fetch_ioctl(fd, STORAGE_DEVICE_GET_SIZE));
} }
if (flag_get_block_size) { if (flag_get_block_size) {
fetch_ioctl(fd, STORAGE_DEVICE_GET_BLOCK_SIZE); TRY(fetch_ioctl(fd, STORAGE_DEVICE_GET_BLOCK_SIZE));
} }
return 0; return 0;