Skip to content

Commit bb3f8db

Browse files
Jay Conrodzx2c4
authored andcommitted
windows: add LockFileEx, UnlockFileEx system calls
Changes in syscall_windows.go were copied from internal/syscall/syscall_windows.go. zsyscall_windows.go was regenerated by running 'go generate -tags=generate golang.org/x/sys/windows' using a toolchain built from tip (after CL 196122). These functions are called by cmd/go/internal/lockedfile via internal/syscall/windows. I'd like to copy lockedfile into another project (CL 197299), but these functions need to be exposed here in order to do so. We may need these in x/mod eventually, too. Change-Id: I2033106d2ba65009e764591bfe5702f4d41dffdd Reviewed-on: https://go-review.googlesource.com/c/sys/+/198060 Run-TryBot: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
1 parent c990c68 commit bb3f8db

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

windows/syscall_windows.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ const (
5757
FILE_VOLUME_IS_COMPRESSED = 0x00008000
5858
FILE_VOLUME_QUOTAS = 0x00000020
5959

60+
// Flags for LockFileEx.
61+
LOCKFILE_FAIL_IMMEDIATELY = 0x00000001
62+
LOCKFILE_EXCLUSIVE_LOCK = 0x00000002
63+
6064
// Return values of SleepEx and other APC functions
6165
STATUS_USER_APC = 0x000000C0
6266
WAIT_IO_COMPLETION = STATUS_USER_APC
@@ -160,6 +164,8 @@ func NewCallbackCDecl(fn interface{}) uintptr {
160164
//sys DeleteFile(path *uint16) (err error) = DeleteFileW
161165
//sys MoveFile(from *uint16, to *uint16) (err error) = MoveFileW
162166
//sys MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) = MoveFileExW
167+
//sys LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error)
168+
//sys UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error)
163169
//sys GetComputerName(buf *uint16, n *uint32) (err error) = GetComputerNameW
164170
//sys GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) = GetComputerNameExW
165171
//sys SetEndOfFile(handle Handle) (err error)

windows/zsyscall_windows.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)