]> Cypherpunks repositories - gostls13.git/commitdiff
os: add support for long path names on aix RemoveAll
authorTobias Klauser <tklauser@distanz.ch>
Fri, 2 Nov 2018 08:12:08 +0000 (09:12 +0100)
committerTobias Klauser <tobias.klauser@gmail.com>
Fri, 2 Nov 2018 13:21:12 +0000 (13:21 +0000)
Follow CL 146020 and enable RemoveAll based on Unlinkat and Openat on
aix.

Updates #27029

Change-Id: I78b34ed671166ee6fa651d5f2025b88548ee6c68
Reviewed-on: https://go-review.googlesource.com/c/146937
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Clément Chigot <clement.chigot@atos.net>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/internal/syscall/unix/asm_solaris.s
src/internal/syscall/unix/at_aix.go [new file with mode: 0644]
src/internal/syscall/unix/at_libc.go [new file with mode: 0644]
src/internal/syscall/unix/at_solaris.go
src/os/removeall_at.go
src/os/removeall_noat.go
src/os/removeall_test.go

index a7ad26df9bbb7bf47205ca15607123b99c5ee8c5..20573383158616fe9afb037b78aed5ed504193b2 100644 (file)
@@ -6,5 +6,5 @@
 
 // System calls for Solaris are implemented in runtime/syscall_solaris.go
 
-TEXT ·sysvicall6(SB),NOSPLIT,$0-88
+TEXT ·syscall6(SB),NOSPLIT,$0-88
        JMP     syscall·sysvicall6(SB)
diff --git a/src/internal/syscall/unix/at_aix.go b/src/internal/syscall/unix/at_aix.go
new file mode 100644 (file)
index 0000000..425df98
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package unix
+
+//go:cgo_import_dynamic libc_fstatat fstatat "libc.a/shr_64.o"
+//go:cgo_import_dynamic libc_openat openat "libc.a/shr_64.o"
+//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.a/shr_64.o"
+
+const (
+       AT_REMOVEDIR        = 0x1
+       AT_SYMLINK_NOFOLLOW = 0x1
+)
diff --git a/src/internal/syscall/unix/at_libc.go b/src/internal/syscall/unix/at_libc.go
new file mode 100644 (file)
index 0000000..6c3a8c9
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build aix solaris
+
+package unix
+
+import (
+       "syscall"
+       "unsafe"
+)
+
+//go:linkname procFstatat libc_fstatat
+//go:linkname procOpenat libc_openat
+//go:linkname procUnlinkat libc_unlinkat
+
+var (
+       procFstatat,
+       procOpenat,
+       procUnlinkat uintptr
+)
+
+func Unlinkat(dirfd int, path string, flags int) error {
+       p, err := syscall.BytePtrFromString(path)
+       if err != nil {
+               return err
+       }
+
+       _, _, errno := syscall6(uintptr(unsafe.Pointer(&procUnlinkat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0)
+       if errno != 0 {
+               return errno
+       }
+
+       return nil
+}
+
+func Openat(dirfd int, path string, flags int, perm uint32) (int, error) {
+       p, err := syscall.BytePtrFromString(path)
+       if err != nil {
+               return 0, err
+       }
+
+       fd, _, errno := syscall6(uintptr(unsafe.Pointer(&procOpenat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0)
+       if errno != 0 {
+               return 0, errno
+       }
+
+       return int(fd), nil
+}
+
+func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error {
+       p, err := syscall.BytePtrFromString(path)
+       if err != nil {
+               return err
+       }
+
+       _, _, errno := syscall6(uintptr(unsafe.Pointer(&procFstatat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+       if errno != 0 {
+               return errno
+       }
+
+       return nil
+}
index d63ee990fda0430c587768a11041f2c9dce95408..e917c4fc9be11bb74f048655fa9df14349cf2d3b 100644 (file)
@@ -4,72 +4,16 @@
 
 package unix
 
-import (
-       "syscall"
-       "unsafe"
-)
+import "syscall"
 
-// Implemented in runtime/syscall_solaris.go.
-func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+// Implemented as sysvicall6 in runtime/syscall_solaris.go.
+func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
 
 //go:cgo_import_dynamic libc_fstatat fstatat "libc.so"
 //go:cgo_import_dynamic libc_openat openat "libc.so"
 //go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so"
 
-//go:linkname procFstatat libc_fstatat
-//go:linkname procOpenat libc_openat
-//go:linkname procUnlinkat libc_unlinkat
-
-var (
-       procFstatat,
-       procOpenat,
-       procUnlinkat uintptr
+const (
+       AT_REMOVEDIR        = 0x1
+       AT_SYMLINK_NOFOLLOW = 0x1000
 )
-
-const AT_REMOVEDIR = 0x1
-const AT_SYMLINK_NOFOLLOW = 0x1000
-
-func Unlinkat(dirfd int, path string, flags int) error {
-       var p *byte
-       p, err := syscall.BytePtrFromString(path)
-       if err != nil {
-               return err
-       }
-
-       _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procUnlinkat)), 3, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), 0, 0, 0)
-       if errno != 0 {
-               return errno
-       }
-
-       return nil
-}
-
-func Openat(dirfd int, path string, flags int, perm uint32) (int, error) {
-       var p *byte
-       p, err := syscall.BytePtrFromString(path)
-       if err != nil {
-               return 0, err
-       }
-
-       fd, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procOpenat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0)
-       if errno != 0 {
-               return 0, errno
-       }
-
-       return int(fd), nil
-}
-
-func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error {
-       var p *byte
-       p, err := syscall.BytePtrFromString(path)
-       if err != nil {
-               return err
-       }
-
-       _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procFstatat)), 4, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
-       if errno != 0 {
-               return errno
-       }
-
-       return nil
-}
index 12d8152bec9cb6d7ae00920ab43c0e69bf8fa692..eb220bd103f0c1fe4ba93eabac9d5f7bcfdb83de 100644 (file)
@@ -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 freebsd linux netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
 
 package os
 
index f8af0da87f6186a9761111ee854b0a4187b231b2..d1dd43ff6ac44d41cbf7776d3102d8c5520baad3 100644 (file)
@@ -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 !linux,!darwin,!freebsd,!openbsd,!netbsd,!dragonfly,!solaris
+// +build !aix,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris
 
 package os
 
index 4daf8c298b3ac42f59484d139cf5e6bc6d83b0a9..5eec8cd1547310ec2549e65c5f7870a39510bd6e 100644 (file)
@@ -162,7 +162,7 @@ func TestRemoveAllLarge(t *testing.T) {
 
 func TestRemoveAllLongPath(t *testing.T) {
        switch runtime.GOOS {
-       case "linux", "darwin", "freebsd", "openbsd", "netbsd", "dragonfly", "solaris":
+       case "aix", "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
                break
        default:
                t.Skip("skipping for not implemented platforms")
@@ -212,7 +212,7 @@ func TestRemoveAllLongPath(t *testing.T) {
 
 func TestRemoveAllDot(t *testing.T) {
        switch runtime.GOOS {
-       case "linux", "darwin", "freebsd", "openbsd", "netbsd", "dragonfly", "solaris":
+       case "aix", "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "solaris":
                break
        default:
                t.Skip("skipping for not implemented platforms")