]> Cypherpunks repositories - gostls13.git/commitdiff
os: add AIX operating system
authorClément Chigot <clement.chigot@atos.net>
Fri, 28 Sep 2018 13:57:27 +0000 (15:57 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 11 Oct 2018 15:41:04 +0000 (15:41 +0000)
This commit adds AIX operating system to os package for ppc64
architecture.

Updates: #25893

Change-Id: Ieb9a2b3ac5b9abd3b5ab68eb732c17b6256d624d
Reviewed-on: https://go-review.googlesource.com/c/138725
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

28 files changed:
src/os/dir_unix.go
src/os/env_unix_test.go
src/os/error_posix.go
src/os/error_unix.go
src/os/error_unix_test.go
src/os/exec/exec_posix_test.go
src/os/exec/lp_unix.go
src/os/exec/lp_unix_test.go
src/os/exec_posix.go
src/os/exec_unix.go
src/os/executable_path.go
src/os/file_posix.go
src/os/file_unix.go
src/os/os_unix_test.go
src/os/path_unix.go
src/os/pipe_bsd.go
src/os/signal/internal/pty/pty.go
src/os/signal/signal_test.go
src/os/signal/signal_unix.go
src/os/stat_aix.go [new file with mode: 0644]
src/os/stat_unix.go
src/os/sys_aix.go [new file with mode: 0644]
src/os/sys_unix.go
src/os/user/cgo_lookup_unix.go
src/os/user/lookup_stubs.go
src/os/user/lookup_unix.go
src/os/user/lookup_unix_test.go
src/os/wait_unimp.go

index 79d61c783f18c83c4b74ae4930e42fe9806a3c2f..7a3ef47ce21fa42b4fd4635caf5c67e5c3895e9f 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
index f7b67ebbb80d6a77d609ab141e60e8f8551929f1..89430b3e2040989d4512ed5635b4f04a724963e0 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_test
 
index 3c81b41706fad210c8dd07f5eb1547e1ede54045..0478ba676aa7b9b36a7ac29d1354b9d14d5330ef 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 js,wasm linux nacl netbsd openbsd solaris windows
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows
 
 package os
 
index a9d798b39153351469e38b837213d9f3217c23e0..bb6bbcc1e6c1590f6f5151a4e5c8f27f2854e6cc 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
index 8db98676d106ba9f41013738f5b7db7006f42557..c47af56332048a7e23ec2100c2e7d6d3154b232e 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os_test
 
index 865b6c3ced28915da50af7cfa89e62d3ab91ec6d..46799cdbdb67a943c6864e1c6ead41caef10af95 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 exec_test
 
index e098ff8e1d5b740d4ccb3f8bb6206d271bcd6921..799e0b4eeb922515814db8e44eb91d091a9c2b60 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 nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
 
 package exec
 
index d467acf5dba2ceaed65558b19bf556f9ffbddd27..e4656cafb8b4a54167b5d714ddaa84cfb83e7365 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 exec
 
index e837e1c4d998f87d3c36b440078db0c27a6749d1..1e60365dba4de633ff4f418af34a9297f968c4c4 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 js,wasm linux nacl netbsd openbsd solaris windows
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows
 
 package os
 
index b07543e550a080fa2a3afae90809a8f6147c8aff..abae5a2feb33999dea27e866020f21d0238fabb2 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
index 057e6a72f4e6153b8efc0896e7386bf6d8002e78..7b8b83652c8953fc4f19ef12568d3aff7f3d86f2 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 openbsd
+// +build aix openbsd
 
 package os
 
index 7cfafc8fde3953d6cf8d93a05a901831b8361673..544d0ad55d4d901276d69522e7a7be277f722a6c 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 js,wasm linux nacl netbsd openbsd solaris windows
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows
 
 package os
 
index cb90b7073580e6c36d1adc278ae977275d761be5..0ca34b070da8d04c5853cdf965b11a132aee932b 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
index 1077d7861357cb9064b4e013668acc7f890837db..0317f7257ec516bfcd16d5dc75416cb83385f909 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_test
 
index b2e0bca0df1eb298438de591d018bd6db40c245f..3cb0e3acc4de0877893c2043d0d2b36dfce9ba11 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
index 9735988f324d3b84e08f5674fa73646575d8cd7e..dc4c951a28638a214bbfbabfe3e05fc585f4f2fb 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 js,wasm nacl solaris
+// +build aix darwin dragonfly js,wasm nacl solaris
 
 package os
 
index c4c1567fce0b314f9acd386b6fa1a4aef36ccec9..c1c7fcffc54b560418aa9ee69f56011793929d3b 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,!android netbsd openbsd
+// +build aix darwin dragonfly freebsd linux,!android netbsd openbsd
 // +build cgo
 
 // Package pty is a simple pseudo-terminal package for Unix systems,
index 3d79c7a8619a89499fcf19780f3abc2f1561247e..ecb05fd16c3e7e15508e43d170131c31fe7cd611 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 signal
 
index 28fbb5499597daa9fa2da9beb65ff17d0eeec21b..7fa634f15ad83a006167a5d449ecaf3d113662cc 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 js,wasm linux nacl netbsd openbsd solaris windows
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows
 
 package signal
 
diff --git a/src/os/stat_aix.go b/src/os/stat_aix.go
new file mode 100644 (file)
index 0000000..a37c9fd
--- /dev/null
@@ -0,0 +1,51 @@
+// 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 os
+
+import (
+       "syscall"
+       "time"
+)
+
+func fillFileStatFromSys(fs *fileStat, name string) {
+       fs.name = basename(name)
+       fs.size = int64(fs.sys.Size)
+       fs.modTime = stTimespecToTime(fs.sys.Mtim)
+       fs.mode = FileMode(fs.sys.Mode & 0777)
+       switch fs.sys.Mode & syscall.S_IFMT {
+       case syscall.S_IFBLK:
+               fs.mode |= ModeDevice
+       case syscall.S_IFCHR:
+               fs.mode |= ModeDevice | ModeCharDevice
+       case syscall.S_IFDIR:
+               fs.mode |= ModeDir
+       case syscall.S_IFIFO:
+               fs.mode |= ModeNamedPipe
+       case syscall.S_IFLNK:
+               fs.mode |= ModeSymlink
+       case syscall.S_IFREG:
+               // nothing to do
+       case syscall.S_IFSOCK:
+               fs.mode |= ModeSocket
+       }
+       if fs.sys.Mode&syscall.S_ISGID != 0 {
+               fs.mode |= ModeSetgid
+       }
+       if fs.sys.Mode&syscall.S_ISUID != 0 {
+               fs.mode |= ModeSetuid
+       }
+       if fs.sys.Mode&syscall.S_ISVTX != 0 {
+               fs.mode |= ModeSticky
+       }
+}
+
+func stTimespecToTime(ts syscall.StTimespec_t) time.Time {
+       return time.Unix(int64(ts.Sec), int64(ts.Nsec))
+}
+
+// For testing.
+func atime(fi FileInfo) time.Time {
+       return stTimespecToTime(fi.Sys().(*syscall.Stat_t).Atim)
+}
index 856b49929f322ba0b46e8360ffa68411e498c89c..4f85dcea077c613c5ab075244c9a50dab014e351 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 js,wasm linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
 
 package os
 
diff --git a/src/os/sys_aix.go b/src/os/sys_aix.go
new file mode 100644 (file)
index 0000000..53a40f2
--- /dev/null
@@ -0,0 +1,26 @@
+// 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 os
+
+import "syscall"
+
+// gethostname syscall cannot be used because it also returns the domain.
+// Therefore, hostname is retrieve with uname syscall and the Nodename field.
+
+func hostname() (name string, err error) {
+       var u syscall.Utsname
+       if errno := syscall.Uname(&u); errno != nil {
+               return "", NewSyscallError("uname", errno)
+       }
+       b := make([]byte, len(u.Nodename))
+       i := 0
+       for ; i < len(u.Nodename); i++ {
+               if u.Nodename[i] == 0 {
+                       break
+               }
+               b[i] = byte(u.Nodename[i])
+       }
+       return string(b[:i]), nil
+}
index 3c63c104097c416b15fe07331107e7cf1b330884..8491bad2421ae8e403ae28a27420e52009796fa3 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 ccb22782460a2ba42c8eedbe00f0cc7bca1c4e1e..856ed28de86041e1e957c5bda1ea99e4763569bd 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 !android,linux netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd !android,linux netbsd openbsd solaris
 // +build cgo,!osusergo
 
 package user
index 9fc03c65d95ac470436a50bae802942281dc727e..61bf1dc7a6f7704f1f746843ec4c38e8ceb7685f 100644 (file)
@@ -65,8 +65,8 @@ func current() (*User, error) {
 }
 
 func listGroups(*User) ([]string, error) {
-       if runtime.GOOS == "android" {
-               return nil, errors.New("user: GroupIds not implemented on Android")
+       if runtime.GOOS == "android" || runtime.GOOS == "aix" {
+               return nil, errors.New(fmt.Sprintf("user: GroupIds not implemented on %s", runtime.GOOS))
        }
        return nil, errors.New("user: GroupIds requires cgo")
 }
index c4e9ba1e818891c41206465696a6f6c0ccb5389c..be62f4d0c3ef3def57c7de8c0244f2e7a75f8baf 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 js,wasm !android,linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd js,wasm !android,linux nacl netbsd openbsd solaris
 // +build !cgo osusergo
 
 package user
index 02c88ab87574c78e9a19996346b8b5dc97dcf5c2..65fe0656de66a099d30d575aa74c1cd1dad9b40e 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 !android,linux nacl netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd !android,linux nacl netbsd openbsd solaris
 // +build !cgo
 
 package user
index 3d8210f5bdceee89f581cc7eda40b9e0e1f82906..d070604600131b63b5b713639d5ca80ebacfd81c 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 js,wasm nacl netbsd openbsd solaris
+// +build aix darwin dragonfly js,wasm nacl netbsd openbsd solaris
 
 package os