aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_darwin.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2023-06-02 14:24:44 +0200
committerJakob Unterwurzacher2026-07-16 22:07:54 +0200
commitb499d38b23f209eb49cbc37d3acd2f9444f5654f (patch)
tree68a6e2c6661636f5f0f6917fd0b734f1212f4bf2 /internal/syscallcompat/sys_darwin.go
parent2f487597f9cabe372a96eecc6007cba1fa9526ac (diff)
fusefrontend: sharedstorage: use byte-range lock on file header creation
Multiple host writing to the same empty file at the same time could have overwritten each other's newly created file header, leading to data corruption. Fix the race by placing a byte-range lock on the file when creating the file header.
Diffstat (limited to 'internal/syscallcompat/sys_darwin.go')
-rw-r--r--internal/syscallcompat/sys_darwin.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go
index 52d4e0f..17e6a9e 100644
--- a/internal/syscallcompat/sys_darwin.go
+++ b/internal/syscallcompat/sys_darwin.go
@@ -33,6 +33,10 @@ const (
// On Darwin we use O_SYMLINK which allows opening a symlink itself.
// On Linux, we only have O_NOFOLLOW.
OpenatFlagNofollowSymlink = unix.O_SYMLINK
+
+ // F_OFD_SETLKW only exists on Linux. On Darwin, fall back to F_SETLKW as a
+ // flawed replacement.
+ F_OFD_SETLKW = unix.F_SETLKW
)
// Unfortunately fsetattrlist does not have a syscall wrapper yet.