]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: use SYS_GETDENTS64 on linux/mips64{,le}
authorTobias Klauser <tklauser@distanz.ch>
Wed, 31 Jan 2018 12:59:00 +0000 (13:59 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 31 Jan 2018 20:42:49 +0000 (20:42 +0000)
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>
22 files changed:
src/syscall/syscall_linux.go
src/syscall/syscall_linux_386.go
src/syscall/syscall_linux_amd64.go
src/syscall/syscall_linux_arm.go
src/syscall/syscall_linux_arm64.go
src/syscall/syscall_linux_mips64x.go
src/syscall/syscall_linux_mipsx.go
src/syscall/syscall_linux_ppc64x.go
src/syscall/syscall_linux_s390x.go
src/syscall/zsyscall_linux_386.go
src/syscall/zsyscall_linux_amd64.go
src/syscall/zsyscall_linux_arm.go
src/syscall/zsyscall_linux_arm64.go
src/syscall/zsyscall_linux_mips.go
src/syscall/zsyscall_linux_mips64.go
src/syscall/zsyscall_linux_mips64le.go
src/syscall/zsyscall_linux_mipsle.go
src/syscall/zsyscall_linux_ppc64.go
src/syscall/zsyscall_linux_ppc64le.go
src/syscall/zsyscall_linux_s390x.go
src/syscall/ztypes_linux_mips64.go
src/syscall/ztypes_linux_mips64le.go

index 3fb9b1aa3f30b1f3e41212234625fb534cff48b8..d2cb7c1afe7c38d6c4c31c1262eb12fe8ecfcac3 100644 (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) {
index 2c5d9a3eee79a797c445f6c45502afae3a5a237c..13b9e2ece53a8a1043ad9acb6990f2ca3c322b17 100644 (file)
@@ -11,7 +11,6 @@ import "unsafe"
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS32
 )
 
index eaba868f89491c6574addf62a99bf00f8718ed1b..4b4aa6d4144ec3b475da4aa0184503025f1fb9b6 100644 (file)
@@ -6,7 +6,6 @@ package syscall
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS
 )
 
index 5c652b2e5bfce582ec79a1c76e64cdbd532538dd..5ccab9bb74bf35885ca6d93ef16cada4a738e595 100644 (file)
@@ -8,7 +8,6 @@ import "unsafe"
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS32
 )
 
index 12b9ebcb4327a09c81179e9221117af80d53b567..27c351d7bd13888659ae7bc7313384f419a0c0d3 100644 (file)
@@ -6,7 +6,6 @@ package syscall
 
 const (
        _SYS_dup       = SYS_DUP3
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS
 )
 
index e4bc77530c9793db15cf0b38359f08db3eba644c..d9eba62b0671d67b792bc5aa3671ba49e33be2b8 100644 (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
 )
 
index 1da265d3c450b5e1375d47b5e3caf535f6608fd3..92785e1596f489ae22947c3c5e19f0eeadf14cd4 100644 (file)
@@ -11,7 +11,6 @@ import "unsafe"
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS
 )
 
index 55ade887ecce245cad286b30139565bac5bf7218..f743b77163a7e96387904b3686d02abdafc5308f 100644 (file)
@@ -9,7 +9,6 @@ package syscall
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS
 )
 
index 8f3bbfc6f74c08a0782aeb71c69109d2cbac1c87..6bd9744bdfb9ad4f3f2bb9db79793938cf838b83 100644 (file)
@@ -8,7 +8,6 @@ import "unsafe"
 
 const (
        _SYS_dup       = SYS_DUP2
-       _SYS_getdents  = SYS_GETDENTS64
        _SYS_setgroups = SYS_SETGROUPS
 )
 
index 8955fca33673245f1cbb9e8b31e069b1cdf1c59d..86f8ec15fa9ab454c33bfa358391ea5c446cf046 100644 (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)
index 34cbed812cbb1354e43539abbfb20523a2ff88ae..6545d1a159671a6fa0799b0878caa4ca85f29a56 100644 (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)
index c9fa1c86e2db83c6021cd99ff334ca7dfcddd4b3..0f0464bf1ce752395b752fc18ec47b47a6872c50 100644 (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)
index a694b83b0bf7268cd820d01c85c3deb2fa8246dc..27470ac0c9cdf730be7838d6143f74a9833e10ce 100644 (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)
index 5aa984d780044deb938bb7f7c2b3355a76cec71f..6b26f7bb926f79d96f3f9126768994ebe5b8bb80 100644 (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)
index 110b35870ae8f95ed62c43ab37255623ae25624e..00a8f7f0c06ad48ee123e95a706f5959b9558550 100644 (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)
index 23597f83885ff535f1e2be1a2d5170246af47afa..97a68ff9e84017e8869f35d88c4ae7fa21099cd9 100644 (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)
index 07825a3b807b95919c0cfb46cfdd124f8a83151c..face54ba284a439f99df0268623ea437bf90e61f 100644 (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)
index 56fb3b8d931103158e9eb1fe833958f6a923c0d3..7df49c728ac4e33422080af55fd2436be4424dbe 100644 (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)
index d08279f4fb3848859a6a0b976701df6c25cb9243..f073f7dbd112913e2b36e2c027d904313411d519 100644 (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)
index e8f1a70b436cac074c6f126a63d557df9bbb6c30..689f2f472c908cf042135f9c466ea0f7cd1f1543 100644 (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)
index 925afb9d1c26aaa62574f8c98ffc4494e17188c8..8c5a0d1d76c3a4aa358493efd9f9d94ed5e0cc17 100644 (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
 }
 
index 925afb9d1c26aaa62574f8c98ffc4494e17188c8..8c5a0d1d76c3a4aa358493efd9f9d94ed5e0cc17 100644 (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
 }