diff --git a/console_other.go b/console_other.go index 968c577..3c0be9a 100644 --- a/console_other.go +++ b/console_other.go @@ -1,5 +1,5 @@ -//go:build !darwin && !freebsd && !linux && !netbsd && !openbsd && !windows && !zos -// +build !darwin,!freebsd,!linux,!netbsd,!openbsd,!windows,!zos +//go:build !aix && !darwin && !freebsd && !linux && !netbsd && !openbsd && !windows && !zos +// +build !aix,!darwin,!freebsd,!linux,!netbsd,!openbsd,!windows,!zos /* Copyright The containerd Authors. diff --git a/console_test.go b/console_test.go index c7d9ae3..02f51ea 100644 --- a/console_test.go +++ b/console_test.go @@ -1,5 +1,5 @@ -//go:build linux || zos || freebsd -// +build linux zos freebsd +//go:build aix || linux || zos || freebsd +// +build aix linux zos freebsd /* Copyright The containerd Authors. diff --git a/console_unix.go b/console_unix.go index aa4c696..4da47d0 100644 --- a/console_unix.go +++ b/console_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || freebsd || linux || netbsd || openbsd || zos -// +build darwin freebsd linux netbsd openbsd zos +//go:build aix || darwin || freebsd || linux || netbsd || openbsd || zos +// +build aix darwin freebsd linux netbsd openbsd zos /* Copyright The containerd Authors. diff --git a/pty_aix.go b/pty_aix.go new file mode 100644 index 0000000..b057d21 --- /dev/null +++ b/pty_aix.go @@ -0,0 +1,31 @@ +//go:build aix +// +build aix + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package console + +import ( + "os" + + "golang.org/x/sys/unix" +) + +// openpt allocates a new pseudo-terminal by opening the /dev/ptmx device +func openpt() (*os.File, error) { + return os.OpenFile("/dev/ptc", unix.O_RDWR|unix.O_NOCTTY|unix.O_CLOEXEC, 0) +} diff --git a/tc_aix_cgo.go b/tc_aix_cgo.go new file mode 100644 index 0000000..c2f8c45 --- /dev/null +++ b/tc_aix_cgo.go @@ -0,0 +1,50 @@ +//go:build aix && cgo +// +build aix,cgo + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package console + +import ( + "golang.org/x/sys/unix" +) + +//#include +import "C" + +const ( + cmdTcGet = unix.TCGETS + cmdTcSet = unix.TCSETS +) + +// ptsname retrieves the name of the first available pts for the given master. +func ptsname(f File) (string, error) { + ptspath, err := C.ptsname(C.int(f.Fd())) + if err != nil { + return "", err + } + return C.GoString(ptspath), nil +} + +// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. +// unlockpt should be called before opening the slave side of a pty. +func unlockpt(f File) error { + if _, err := C.grantpt(C.int(f.Fd())); err != nil { + return err + } + return nil +} diff --git a/tc_aix_nocgo.go b/tc_aix_nocgo.go new file mode 100644 index 0000000..11ad45c --- /dev/null +++ b/tc_aix_nocgo.go @@ -0,0 +1,46 @@ +//go:build aix && !cgo +// +build aix,!cgo + +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +// +// Implementing the functions below requires cgo support. Non-cgo stubs +// versions are defined below to enable cross-compilation of source code +// that depends on these functions, but the resultant cross-compiled +// binaries cannot actually be used. If the stub function(s) below are +// actually invoked they will display an error message and cause the +// calling process to exit. +// + +package console + +import ( + "golang.org/x/sys/unix" +) + +const ( + cmdTcGet = unix.TCGETS + cmdTcSet = unix.TCSETS +) + +func ptsname(f File) (string, error) { + panic("ptsname() support requires cgo.") +} + +func unlockpt(f File) error { + panic("unlockpt() support requires cgo.") +} diff --git a/tc_unix.go b/tc_unix.go index 2ecf188..0d7a5c3 100644 --- a/tc_unix.go +++ b/tc_unix.go @@ -1,5 +1,5 @@ -//go:build darwin || freebsd || linux || netbsd || openbsd || zos -// +build darwin freebsd linux netbsd openbsd zos +//go:build aix || darwin || freebsd || linux || netbsd || openbsd || zos +// +build aix darwin freebsd linux netbsd openbsd zos /* Copyright The containerd Authors.