1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +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 <LibMain/Main.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
static void fetch_ioctl(int fd, int request)
static ErrorOr<void> fetch_ioctl(int fd, int request)
{
u64 value;
if (ioctl(fd, request, &value) < 0) {
perror("ioctl");
exit(1);
}
TRY(Core::System::ioctl(fd, request, &value));
outln("{}", value);
return {};
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -46,10 +43,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
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) {
fetch_ioctl(fd, STORAGE_DEVICE_GET_BLOCK_SIZE);
TRY(fetch_ioctl(fd, STORAGE_DEVICE_GET_BLOCK_SIZE));
}
return 0;