Ver código fonte

unix: fix Getdirentries emulation using Getdents on netbsd, openbsd

CL 182319 used the wrong shift offset, correct and enable the TestGetdirentries.

Change-Id: I45d8d420a071fd79fa1b37642b984d80943f492b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183221
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Yuval Pavel Zholkover 6 anos atrás
pai
commit
a26fa11ef6
3 arquivos alterados com 3 adições e 3 exclusões
  1. 1 1
      unix/getdirentries_test.go
  2. 1 1
      unix/syscall_netbsd.go
  3. 1 1
      unix/syscall_openbsd.go

+ 1 - 1
unix/getdirentries_test.go

@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly
+// +build darwin dragonfly freebsd openbsd netbsd
 
 package unix_test
 

+ 1 - 1
unix/syscall_netbsd.go

@@ -137,7 +137,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
 	if unsafe.Sizeof(*basep) == 8 {
 		return
 	}
-	if off>>4 != 0 {
+	if off>>32 != 0 {
 		// We can't stuff the offset back into a uintptr, so any
 		// future calls would be suspect. Generate an error.
 		// EIO is allowed by getdirentries.

+ 1 - 1
unix/syscall_openbsd.go

@@ -106,7 +106,7 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
 	if unsafe.Sizeof(*basep) == 8 {
 		return
 	}
-	if off>>4 != 0 {
+	if off>>32 != 0 {
 		// We can't stuff the offset back into a uintptr, so any
 		// future calls would be suspect. Generate an error.
 		// EIO was allowed by getdirentries.