2026-02-17 16:58:02 +01:00
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
2026-03-12 06:23:26 +01:00
|
|
|
#include <sys/fcntl.h>
|
2026-02-17 16:58:02 +01:00
|
|
|
|
|
|
|
|
// TODO This C wrapper is required since P/Invoke cannot correctly pass variadic
|
|
|
|
|
// arguments to ioctl on non-Windows platforms.
|
|
|
|
|
// May be fixed in the future:
|
|
|
|
|
// https://github.com/dotnet/runtime/issues/10478
|
|
|
|
|
// https://github.com/dotnet/runtime/pull/112884
|
|
|
|
|
// https://github.com/dotnet/runtime/issues/48796
|
|
|
|
|
|
|
|
|
|
// Wrapper for ioctl that takes a pointer to uint32
|
|
|
|
|
int ioctl_uint32(int fd, unsigned long request, unsigned int *value)
|
|
|
|
|
{
|
|
|
|
|
return ioctl(fd, request, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wrapper for ioctl that takes a pointer to uint64
|
|
|
|
|
int ioctl_uint64(int fd, unsigned long request, unsigned long *value)
|
|
|
|
|
{
|
|
|
|
|
return ioctl(fd, request, value);
|
|
|
|
|
}
|
2026-02-23 20:25:02 +01:00
|
|
|
|
|
|
|
|
// Wrapper for ioctl that takes no argument
|
|
|
|
|
int ioctl_no_arg(int fd, unsigned long request)
|
|
|
|
|
{
|
|
|
|
|
return ioctl(fd, request);
|
|
|
|
|
}
|
2026-03-12 06:23:26 +01:00
|
|
|
|
|
|
|
|
// Wrapper for fcntl to set F_NOCACHE (equivalent to O_DIRECT on Linux)
|
|
|
|
|
int fcntl_nocache(int fd)
|
|
|
|
|
{
|
|
|
|
|
return fcntl(fd, F_NOCACHE, 1);
|
|
|
|
|
}
|