Support LockFileEx syscall in \\wsl$ directory
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
Is your feature request related to a problem? Please describe.
Package management tools such as Go Modules and Rust Cargo use Write/Read Lock of File System. This is an important mechanism for removing conflicts.
The WSL2 shared directory \\wsl$ does not seem to support LockFileEx syscall. I confirmed that smb supports it. It returns an Incorrect function. error with the LOCKFILE_EXCLUSIVE_LOCK flag both set/unset.
To solve this problem, Rust Cargo has added code that ignores lock errors. https://github.com/rust-lang/cargo/pull/7602
Go Modules does not work with WSL and officially replied to Issue that WSL is not supported. https://github.com/golang/go/issues/37461
Describe the solution you'd like
Add locking functionality to the shared file system for a better development experience.
Describe alternatives you've considered
- Added logic to ignore lock errors in package management tools.
- Launch samba server on WSL2.
Additional context
Below is an example of an error with go modules in latest version.
> go mod download # go version 1.14
go: RLock Z:\example\go.mod: Incorrect function.
simple test code to call LockFileEx
package main
import (
"os"
"fmt"
"golang.org/x/sys/windows"
)
const (
reserved = 0
allBytes = ^uint32(0)
)
func main () {
f, err := os.Open("tmp.txt")
if err != nil {
panic(err)
}
lockType := uint32(2) // 0: readlock 2: writelock
ol := new(windows.Overlapped)
err = windows.LockFileEx(windows.Handle(f.Fd()), lockType, reserved, allBytes, allBytes, ol)
if err != nil {
panic(err)
}
fmt.Printf("success lock")
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the provided Go sample and LockFileEx against a \wsl$ path. Then trace the WSL shared filesystem handling for this syscall; done means read and write locks work there without the Incorrect function error reported by Go Modules and Rust Cargo.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, go, rust
- Domain
- operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100