1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

vendor: github.com/containerd/console v1.0.1

full diff: https://github.com/containerd/console/compare/v1.0.0...v1.0.1

Fixes compatibility with current versions of golang.org/x/sys

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-10-20 23:04:02 +02:00
parent 73dc6a680c
commit 4680836f80
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
8 changed files with 68 additions and 31 deletions

View file

@ -127,7 +127,7 @@ github.com/containerd/containerd c623d1b36f09f8ef6536a057bd65
github.com/containerd/fifo f15a3290365b9d2627d189e619ab4008e0069caf github.com/containerd/fifo f15a3290365b9d2627d189e619ab4008e0069caf
github.com/containerd/continuity efbc4488d8fe1bdc16bde3b2d2990d9b3a899165 github.com/containerd/continuity efbc4488d8fe1bdc16bde3b2d2990d9b3a899165
github.com/containerd/cgroups 318312a373405e5e91134d8063d04d59768a1bff github.com/containerd/cgroups 318312a373405e5e91134d8063d04d59768a1bff
github.com/containerd/console 8375c3424e4d7b114e8a90a4a40c8e1b40d1d4e6 # v1.0.0 github.com/containerd/console 5d7e1412f07b502a01029ea20e20e0d2be31fa7c # v1.0.1
github.com/containerd/go-runc 7016d3ce2328dd2cb1192b2076ebd565c4e8df0c github.com/containerd/go-runc 7016d3ce2328dd2cb1192b2076ebd565c4e8df0c
github.com/containerd/typeurl cd3ce7159eae562a4f60ceff37dada11a939d247 # v1.0.1 github.com/containerd/typeurl cd3ce7159eae562a4f60ceff37dada11a939d247 # v1.0.1
github.com/containerd/ttrpc 72bb1b21c5b0a4a107f59dd85f6ab58e564b68d6 # v1.0.1 github.com/containerd/ttrpc 72bb1b21c5b0a4a107f59dd85f6ab58e564b68d6 # v1.0.1

View file

@ -61,18 +61,24 @@ type WinSize struct {
y uint16 y uint16
} }
// Current returns the current processes console // Current returns the current process' console
func Current() Console { func Current() (c Console) {
c, err := ConsoleFromFile(os.Stdin) var err error
if err != nil { // Usually all three streams (stdin, stdout, and stderr)
// stdin should always be a console for the design // are open to the same console, but some might be redirected,
// of this function // so try all three.
panic(err) for _, s := range []*os.File{os.Stderr, os.Stdout, os.Stdin} {
} if c, err = ConsoleFromFile(s); err == nil {
return c return c
}
}
// One of the std streams should always be a console
// for the design of this function.
panic(err)
} }
// ConsoleFromFile returns a console using the provided file // ConsoleFromFile returns a console using the provided file
// nolint:golint
func ConsoleFromFile(f File) (Console, error) { func ConsoleFromFile(f File) (Console, error) {
if err := checkConsole(f); err != nil { if err := checkConsole(f); err != nil {
return nil, err return nil, err

View file

@ -1,4 +1,4 @@
// +build darwin freebsd linux openbsd solaris // +build darwin freebsd linux netbsd openbsd solaris
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.

View file

@ -3,6 +3,6 @@ module github.com/containerd/console
go 1.13 go 1.13
require ( require (
github.com/pkg/errors v0.8.1 github.com/pkg/errors v0.9.1
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f
) )

View file

@ -19,7 +19,6 @@ package console
import ( import (
"fmt" "fmt"
"os" "os"
"unsafe"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -29,18 +28,10 @@ const (
cmdTcSet = unix.TIOCSETA cmdTcSet = unix.TIOCSETA
) )
func ioctl(fd, flag, data uintptr) error {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
return err
}
return nil
}
// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. // 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. // unlockpt should be called before opening the slave side of a pty.
func unlockpt(f *os.File) error { func unlockpt(f *os.File) error {
var u int32 return unix.IoctlSetPointerInt(int(f.Fd()), unix.TIOCPTYUNLK, 0)
return ioctl(f.Fd(), unix.TIOCPTYUNLK, uintptr(unsafe.Pointer(&u)))
} }
// ptsname retrieves the name of the first available pts for the given master. // ptsname retrieves the name of the first available pts for the given master.

View file

@ -19,7 +19,6 @@ package console
import ( import (
"fmt" "fmt"
"os" "os"
"unsafe"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -32,17 +31,13 @@ const (
// unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f. // 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. // unlockpt should be called before opening the slave side of a pty.
func unlockpt(f *os.File) error { func unlockpt(f *os.File) error {
var u int32 return unix.IoctlSetPointerInt(int(f.Fd()), unix.TIOCSPTLCK, 0)
if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCSPTLCK, uintptr(unsafe.Pointer(&u))); err != 0 {
return err
}
return nil
} }
// ptsname retrieves the name of the first available pts for the given master. // ptsname retrieves the name of the first available pts for the given master.
func ptsname(f *os.File) (string, error) { func ptsname(f *os.File) (string, error) {
var u uint32 u, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
if _, _, err := unix.Syscall(unix.SYS_IOCTL, f.Fd(), unix.TIOCGPTN, uintptr(unsafe.Pointer(&u))); err != 0 { if err != nil {
return "", err return "", err
} }
return fmt.Sprintf("/dev/pts/%d", u), nil return fmt.Sprintf("/dev/pts/%d", u), nil

45
vendor/github.com/containerd/console/tc_netbsd.go generated vendored Normal file
View file

@ -0,0 +1,45 @@
/*
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 (
"bytes"
"os"
"golang.org/x/sys/unix"
)
const (
cmdTcGet = unix.TIOCGETA
cmdTcSet = unix.TIOCSETA
)
// 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.
// This does not exist on NetBSD, it does not allocate controlling terminals on open
func unlockpt(f *os.File) error {
return nil
}
// ptsname retrieves the name of the first available pts for the given master.
func ptsname(f *os.File) (string, error) {
ptm, err := unix.IoctlGetPtmget(int(f.Fd()), unix.TIOCPTSNAME)
if err != nil {
return "", err
}
return string(ptm.Sn[:bytes.IndexByte(ptm.Sn[:], 0)]), nil
}

View file

@ -1,4 +1,4 @@
// +build darwin freebsd linux openbsd solaris // +build darwin freebsd linux netbsd openbsd solaris
/* /*
Copyright The containerd Authors. Copyright The containerd Authors.