1
0
mirror of https://github.com/golang/go synced 2024-11-23 22:10:04 -07:00

syscall: use SYS_GETDENTS64 on linux/mips64{,le}

The getdents64 syscall is only available for mips64/mips64le starting
with Linux kernel 3.10. Since mips64le requires at least 4.8 according
to [1] (regarding #16848) using it should be fine.

[1] https://golang.org/wiki/MinimumRequirements

This CL changes the binary layout of type Dirent for mips64/mips64le,
but not the public API. But since the currently used layout doesn't
match the struct linux_dirent returned by the getdents syscall this
should be fine as well.

Fixes #23624

Change-Id: Iaa7306fa6e4442ad2fed41c60b37627a7314f117
Reviewed-on: https://go-review.googlesource.com/91055
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Tobias Klauser 2018-01-31 13:59:00 +01:00 committed by Brad Fitzpatrick
parent 43288467d2
commit d929e40e9a
22 changed files with 15 additions and 35 deletions

View File

@ -831,7 +831,7 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri
//sys Fdatasync(fd int) (err error)
//sys Flock(fd int, how int) (err error)
//sys Fsync(fd int) (err error)
//sys Getdents(fd int, buf []byte) (n int, err error) = _SYS_getdents
//sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64
//sysnb Getpgid(pid int) (pgid int, err error)
func Getpgrp() (pid int) {

View File

@ -11,7 +11,6 @@ import "unsafe"
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS32
)

View File

@ -6,7 +6,6 @@ package syscall
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -8,7 +8,6 @@ import "unsafe"
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS32
)

View File

@ -6,7 +6,6 @@ package syscall
const (
_SYS_dup = SYS_DUP3
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -8,14 +8,7 @@
package syscall
const (
_SYS_dup = SYS_DUP2
// Linux introduced getdents64 syscall for N64 ABI only in 3.10
// (May 21 2013, rev dec33abaafc89bcbd78f85fad0513170415a26d5),
// to support older kernels, we have to use getdents for mips64.
// Also note that struct dirent is different for these two.
// Lookup linux_dirent{,64} in kernel source code for details.
_SYS_getdents = SYS_GETDENTS
_SYS_dup = SYS_DUP2
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -11,7 +11,6 @@ import "unsafe"
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -9,7 +9,6 @@ package syscall
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -8,7 +8,6 @@ import "unsafe"
const (
_SYS_dup = SYS_DUP2
_SYS_getdents = SYS_GETDENTS64
_SYS_setgroups = SYS_SETGROUPS
)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -479,7 +479,7 @@ func Getdents(fd int, buf []byte) (n int, err error) {
} else {
_p0 = unsafe.Pointer(&_zero)
}
r0, _, e1 := Syscall(_SYS_getdents, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
r0, _, e1 := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
n = int(r0)
if e1 != 0 {
err = errnoErr(e1)

View File

@ -130,15 +130,12 @@ type Statfs_t struct {
Spare [5]int64
}
// Note: on mips64, we're using the getdents syscall,
// so the Dirent struct is different.
type Dirent struct {
Ino uint64
Off int64
Reclen uint16
Name [256]int8
Type uint8
Name [256]int8
Pad_cgo_0 [5]byte
}

View File

@ -130,15 +130,12 @@ type Statfs_t struct {
Spare [5]int64
}
// Note: on mips64, we're using the getdents syscall,
// so the Dirent struct is different.
type Dirent struct {
Ino uint64
Off int64
Reclen uint16
Name [256]int8
Type uint8
Name [256]int8
Pad_cgo_0 [5]byte
}