Commit c84c1ab9 authored by Sean Chittenden's avatar Sean Chittenden Committed by Ian Lance Taylor

unix: add flock(3C) support on Solaris

Fixes: golang/go#21410

Change-Id: Ie1971f7d6e0cfe405603e94c538a15dd5f467392
Reviewed-on: https://go-review.googlesource.com/55230
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent e42485b6
......@@ -581,6 +581,7 @@ func IoctlGetTermio(fd int, req uint) (*Termio, error) {
//sys Fchown(fd int, uid int, gid int) (err error)
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
//sys Fdatasync(fd int) (err error)
//sys Flock(fd int, how int) (err error)
//sys Fpathconf(fd int, name int) (val int, err error)
//sys Fstat(fd int, stat *Stat_t) (err error)
//sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error)
......
......@@ -43,6 +43,7 @@ import (
//go:cgo_import_dynamic libc_fchown fchown "libc.so"
//go:cgo_import_dynamic libc_fchownat fchownat "libc.so"
//go:cgo_import_dynamic libc_fdatasync fdatasync "libc.so"
//go:cgo_import_dynamic libc_flock flock "libc.so"
//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so"
//go:cgo_import_dynamic libc_fstat fstat "libc.so"
//go:cgo_import_dynamic libc_fstatvfs fstatvfs "libc.so"
......@@ -163,6 +164,7 @@ import (
//go:linkname procFchown libc_fchown
//go:linkname procFchownat libc_fchownat
//go:linkname procFdatasync libc_fdatasync
//go:linkname procFlock libc_flock
//go:linkname procFpathconf libc_fpathconf
//go:linkname procFstat libc_fstat
//go:linkname procFstatvfs libc_fstatvfs
......@@ -284,6 +286,7 @@ var (
procFchown,
procFchownat,
procFdatasync,
procFlock,
procFpathconf,
procFstat,
procFstatvfs,
......@@ -702,6 +705,14 @@ func Fdatasync(fd int) (err error) {
return
}
func Flock(fd int, how int) (err error) {
_, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0)
if e1 != 0 {
err = e1
}
return
}
func Fpathconf(fd int, name int) (val int, err error) {
r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procFpathconf)), 2, uintptr(fd), uintptr(name), 0, 0, 0, 0)
val = int(r0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment