Compile bug, unresolved import `crate::sys`

WASI doesn't have filesystem locks: WASI/wasi_unstable.witx at main · WebAssembly/WASI · GitHub

It is effectively impossible to implement file locks in a way portable across operating systems. On unix you have fcntl and flock both of which are advisory (meaning all programs need to opt-in to using them) locks. Fcntl are effectively impossible to use correctly when using libraries as locking a file twice from the same program causes a single lock to be taken. Closing any fd for the respective file will unlock this single lock. Flock isn't as portable as fcntl however. See also Cross-platform library for file locking?

2 Likes