Mac doesn't have O_DIRECT, but it has F_NOCACHE

This commit is contained in:
Carl Johnsen
2026-03-12 06:23:26 +01:00
parent a62d23fab4
commit 0be0aa227b
3 changed files with 23 additions and 6 deletions
@@ -1,5 +1,6 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/fcntl.h>
// TODO This C wrapper is required since P/Invoke cannot correctly pass variadic
// arguments to ioctl on non-Windows platforms.
@@ -25,3 +26,9 @@ int ioctl_no_arg(int fd, unsigned long request)
{
return ioctl(fd, request);
}
// Wrapper for fcntl to set F_NOCACHE (equivalent to O_DIRECT on Linux)
int fcntl_nocache(int fd)
{
return fcntl(fd, F_NOCACHE, 1);
}