Commits

Aram Hăvărneanu committed b60dea7

syscall: implement FcntlFlock

Comments (0)

Files changed (3)

src/pkg/syscall/exec_unix.go

 	} else {
 		flag &= ^O_NONBLOCK
 	}
-	_, err = fcntl(fd, F_SETFL, flag)
+	_, err = fcntl(fd, F_SETFL, uintptr(flag))
 	return err
 }
 

src/pkg/syscall/syscall_solaris.go

 	return Utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
 }
 
-//sys	fcntl(fd int, cmd int, arg int) (val int, err error)
+//sys	fcntl(fd int, cmd int, arg uintptr) (val int, err error)
+
+// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
+func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
+	_, err := fcntl(int(fd), cmd, uintptr(unsafe.Pointer(lk)))
+	if err == nil {
+		return nil
+	}
+	return err
+}
 
 func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
 	switch rsa.Addr.Family {

src/pkg/syscall/zsyscall_solaris_amd64.go

 	return
 }
 
-func fcntl(fd int, cmd int, arg int) (val int, err error) {
+func fcntl(fd int, cmd int, arg uintptr) (val int, err error) {
 	r0, _, e1 := Sysvicall6(procfcntl.Addr(), 3, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
 	val = int(r0)
 	if e1 != 0 {