Commit 835f983d authored by Clément Chigot's avatar Clément Chigot Committed by Brad Fitzpatrick

os: add AIX operating system

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/138725Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 69c5830c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os_test
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os_test
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package exec_test
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package exec
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package exec
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build openbsd // +build aix openbsd
package os package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os_test
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 // +build cgo
// Package pty is a simple pseudo-terminal package for Unix systems, // Package pty is a simple pseudo-terminal package for Unix systems,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package signal
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package signal
......
// 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)
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
// 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
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 // +build cgo,!osusergo
package user package user
......
...@@ -65,8 +65,8 @@ func current() (*User, error) { ...@@ -65,8 +65,8 @@ func current() (*User, error) {
} }
func listGroups(*User) ([]string, error) { func listGroups(*User) ([]string, error) {
if runtime.GOOS == "android" { if runtime.GOOS == "android" || runtime.GOOS == "aix" {
return nil, errors.New("user: GroupIds not implemented on Android") return nil, errors.New(fmt.Sprintf("user: GroupIds not implemented on %s", runtime.GOOS))
} }
return nil, errors.New("user: GroupIds requires cgo") return nil, errors.New("user: GroupIds requires cgo")
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 // +build !cgo osusergo
package user package user
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 // +build !cgo
package user package user
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // 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 package os
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment