From 53f7e1a0f02c44d19b8cda178daebe0aa466f352 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 4 Jul 2018 09:04:00 +0200 Subject: macos: fix O_DIRECT build failure O_DIRECT has no direct equivalent on MacOS (check out https://github.com/libuv/libuv/issues/1600 for details). Just define it to zero there. --- internal/fusefrontend/fs.go | 2 +- internal/syscallcompat/sys_darwin.go | 4 ++++ internal/syscallcompat/sys_linux.go | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index 2cdc362..23f5513 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -105,7 +105,7 @@ func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int) { // crypto header, alignment will be off, even if userspace makes aligned // accesses. Running xfstests generic/013 on ext4 used to trigger lots of // EINVAL errors due to missing alignment. Just fall back to buffered IO. - newFlags = newFlags &^ syscall.O_DIRECT + newFlags = newFlags &^ syscallcompat.O_DIRECT return newFlags } diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go index 7f2c541..74681db 100644 --- a/internal/syscallcompat/sys_darwin.go +++ b/internal/syscallcompat/sys_darwin.go @@ -9,6 +9,10 @@ import ( "github.com/hanwen/go-fuse/fuse" ) +// O_DIRECT means oncached I/O on Linux. No direct equivalent on MacOS and defined +// to zero there. +const O_DIRECT = 0 + // Sorry, fallocate is not available on OSX at all and // fcntl F_PREALLOCATE is not accessible from Go. // See https://github.com/rfjakob/gocryptfs/issues/18 if you want to help. diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go index b5b949e..b6f18d2 100644 --- a/internal/syscallcompat/sys_linux.go +++ b/internal/syscallcompat/sys_linux.go @@ -14,6 +14,10 @@ import ( const _FALLOC_FL_KEEP_SIZE = 0x01 +// O_DIRECT means oncached I/O on Linux. No direct equivalent on MacOS and defined +// to zero there. +const O_DIRECT = syscall.O_DIRECT + var preallocWarn sync.Once // EnospcPrealloc preallocates ciphertext space without changing the file -- cgit v1.2.3