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:
parent
66a68a9523
commit
a7dafacced
1 changed files with 5 additions and 8 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue