-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I suspect that OFD locking is broken on 32-bit Linux in both lukko
and base
.
Specifically, we end up calling fcntl64
yet use the 32-bit struct flock
. glibc suffered a similar bug some years ago. The following patch works around the issue although I'm still investigating the portability implications:
diff --git a/src-ofd/Lukko/OFD.hsc b/src-ofd/Lukko/OFD.hsc
index 8d04dae..024cb28 100644
--- a/src-ofd/Lukko/OFD.hsc
+++ b/src-ofd/Lukko/OFD.hsc
@@ -127,21 +127,21 @@ data FLock = FLock { l_type :: CShort
}
instance Storable FLock where
- sizeOf _ = #{size struct flock}
+ sizeOf _ = #{size struct flock64}
alignment _ = #{alignmentcompat struct flock}
poke ptr x = do
fillBytes ptr 0 (sizeOf x)
- #{poke struct flock, l_type} ptr (l_type x)
- #{poke struct flock, l_whence} ptr (l_whence x)
- #{poke struct flock, l_start} ptr (l_start x)
- #{poke struct flock, l_len} ptr (l_len x)
- #{poke struct flock, l_pid} ptr (l_pid x)
+ #{poke struct flock64, l_type} ptr (l_type x)
+ #{poke struct flock64, l_whence} ptr (l_whence x)
+ #{poke struct flock64, l_start} ptr (l_start x)
+ #{poke struct flock64, l_len} ptr (l_len x)
+ #{poke struct flock64, l_pid} ptr (l_pid x)
peek ptr = do
- x1 <- #{peek struct flock, l_type} ptr
- x2 <- #{peek struct flock, l_whence} ptr
- x3 <- #{peek struct flock, l_start} ptr
- x4 <- #{peek struct flock, l_len} ptr
- x5 <- #{peek struct flock, l_pid} ptr
+ x1 <- #{peek struct flock64, l_type} ptr
+ x2 <- #{peek struct flock64, l_whence} ptr
+ x3 <- #{peek struct flock64, l_start} ptr
+ x4 <- #{peek struct flock64, l_len} ptr
+ x5 <- #{peek struct flock64, l_pid} ptr
return (FLock x1 x2 x3 x4 x5)
lockImpl :: Maybe Handle -> FD -> String -> LockMode -> Bool -> IO Bool
Metadata
Metadata
Assignees
Labels
No labels