vendor: update github.com/containerd/console

Signed-off-by: Edward Pilatowicz <edward.pilatowicz@oracle.com>
This commit is contained in:
Edward Pilatowicz 2017-07-25 17:18:13 -07:00
parent 949d4903ee
commit 534a137ed3
8 changed files with 168 additions and 52 deletions

View File

@ -1,6 +1,6 @@
github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6
github.com/containerd/go-runc 2774a2ea124a5c2d0aba13b5c2dd8a5a9a48775d
github.com/containerd/console 2ce1c681f3c3c0dfa7d0af289428d36567c9a6bc
github.com/containerd/console 76d18fd1d66972718ab2284449591db0b3cdb4de
github.com/containerd/cgroups 4fd64a776f25b5540cddcb72eea6e35e58baca6e
github.com/docker/go-metrics 8fd5772bf1584597834c6f7961a530f06cbfbb87
github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9

View File

@ -1,10 +1,9 @@
// +build darwin freebsd linux
// +build darwin freebsd linux solaris
package console
import (
"os"
"unsafe"
"golang.org/x/sys/unix"
)
@ -50,11 +49,7 @@ func (m *master) Close() error {
}
func (m *master) Resize(ws WinSize) error {
return ioctl(
m.f.Fd(),
uintptr(unix.TIOCSWINSZ),
uintptr(unsafe.Pointer(&ws)),
)
return tcswinsz(m.f.Fd(), ws)
}
func (m *master) ResizeFrom(c Console) error {
@ -103,15 +98,7 @@ func (m *master) DisableEcho() error {
}
func (m *master) Size() (WinSize, error) {
var ws WinSize
if err := ioctl(
m.f.Fd(),
uintptr(unix.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)),
); err != nil {
return ws, err
}
return ws, nil
return tcgwinsz(m.f.Fd())
}
func (m *master) Fd() uintptr {

View File

@ -16,6 +16,26 @@ func tcset(fd uintptr, p *unix.Termios) error {
return ioctl(fd, unix.TIOCSETA, uintptr(unsafe.Pointer(p)))
}
func tcgwinsz(fd uintptr) (WinSize, error) {
var ws WinSize
if err := ioctl(
fd,
uintptr(unix.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)),
); err != nil {
return ws, err
}
return ws, nil
}
func tcswinsz(fd uintptr, ws WinSize) error {
return ioctl(
fd,
uintptr(unix.TIOCSWINSZ),
uintptr(unsafe.Pointer(&ws)),
)
}
func ioctl(fd, flag, data uintptr) error {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
return err

View File

@ -16,6 +16,26 @@ func tcset(fd uintptr, p *unix.Termios) error {
return ioctl(fd, unix.TIOCSETA, uintptr(unsafe.Pointer(p)))
}
func tcgwinsz(fd uintptr) (WinSize, error) {
var ws WinSize
if err := ioctl(
fd,
uintptr(unix.TIOCGWINSZ),
uintptr(unsafe.Pointer(&ws)),
); err != nil {
return ws, err
}
return ws, nil
}
func tcswinsz(fd uintptr, ws WinSize) error {
return ioctl(
fd,
uintptr(unix.TIOCSWINSZ),
uintptr(unsafe.Pointer(&ws)),
)
}
func ioctl(fd, flag, data uintptr) error {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
return err

View File

@ -8,19 +8,6 @@ import (
"golang.org/x/sys/unix"
)
func tcget(fd uintptr, p *unix.Termios) error {
termios, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
if err != nil {
return err
}
*p = *termios
return nil
}
func tcset(fd uintptr, p *unix.Termios) error {
return unix.IoctlSetTermios(int(fd), unix.TCSETS, p)
}
func ioctl(fd, flag, data uintptr) error {
if _, _, err := unix.Syscall(unix.SYS_IOCTL, fd, flag, data); err != 0 {
return err
@ -43,25 +30,3 @@ func ptsname(f *os.File) (string, error) {
}
return fmt.Sprintf("/dev/pts/%d", n), nil
}
func saneTerminal(f *os.File) error {
var termios unix.Termios
if err := tcget(f.Fd(), &termios); err != nil {
return err
}
// Set -onlcr so we don't have to deal with \r.
termios.Oflag &^= unix.ONLCR
return tcset(f.Fd(), &termios)
}
func cfmakeraw(t unix.Termios) unix.Termios {
t.Iflag = t.Iflag & ^uint32((unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON))
t.Oflag = t.Oflag & ^uint32(unix.OPOST)
t.Lflag = t.Lflag & ^(uint32(unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN))
t.Cflag = t.Cflag & ^(uint32(unix.CSIZE | unix.PARENB))
t.Cflag = t.Cflag | unix.CS8
t.Cc[unix.VMIN] = 1
t.Cc[unix.VTIME] = 0
return t
}

28
vendor/github.com/containerd/console/tc_solaris_cgo.go generated vendored Normal file
View File

@ -0,0 +1,28 @@
// +build solaris,cgo
package console
import (
"os"
)
//#include <stdlib.h>
import "C"
// ptsname retrieves the name of the first available pts for the given master.
func ptsname(f *os.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 *os.File) error {
if _, err := C.grantpt(C.int(f.Fd())); err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,24 @@
// +build solaris,!cgo
//
// 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 (
"os"
)
func ptsname(f *os.File) (string, error) {
panic("ptsname() support requires cgo.")
}
func unlockpt(f *os.File) error {
panic("unlockpt() support requires cgo.")
}

72
vendor/github.com/containerd/console/tc_unix.go generated vendored Normal file
View File

@ -0,0 +1,72 @@
// +build linux solaris
package console
import (
"os"
"golang.org/x/sys/unix"
)
func tcget(fd uintptr, p *unix.Termios) error {
termios, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
if err != nil {
return err
}
*p = *termios
return nil
}
func tcset(fd uintptr, p *unix.Termios) error {
return unix.IoctlSetTermios(int(fd), unix.TCSETS, p)
}
func tcgwinsz(fd uintptr) (WinSize, error) {
var ws WinSize
uws, err := unix.IoctlGetWinsize(int(fd), unix.TIOCGWINSZ)
if err != nil {
return ws, err
}
// Translate from unix.Winsize to console.WinSize
ws.Height = uws.Row
ws.Width = uws.Col
ws.x = uws.Xpixel
ws.y = uws.Ypixel
return ws, nil
}
func tcswinsz(fd uintptr, ws WinSize) error {
// Translate from console.WinSize to unix.Winsize
var uws unix.Winsize
uws.Row = ws.Height
uws.Col = ws.Width
uws.Xpixel = ws.x
uws.Ypixel = ws.y
return unix.IoctlSetWinsize(int(fd), unix.TIOCSWINSZ, &uws)
}
func saneTerminal(f *os.File) error {
var termios unix.Termios
if err := tcget(f.Fd(), &termios); err != nil {
return err
}
// Set -onlcr so we don't have to deal with \r.
termios.Oflag &^= unix.ONLCR
return tcset(f.Fd(), &termios)
}
func cfmakeraw(t unix.Termios) unix.Termios {
t.Iflag = t.Iflag & ^uint32((unix.IGNBRK | unix.BRKINT | unix.PARMRK | unix.ISTRIP | unix.INLCR | unix.IGNCR | unix.ICRNL | unix.IXON))
t.Oflag = t.Oflag & ^uint32(unix.OPOST)
t.Lflag = t.Lflag & ^(uint32(unix.ECHO | unix.ECHONL | unix.ICANON | unix.ISIG | unix.IEXTEN))
t.Cflag = t.Cflag & ^(uint32(unix.CSIZE | unix.PARENB))
t.Cflag = t.Cflag | unix.CS8
t.Cc[unix.VMIN] = 1
t.Cc[unix.VTIME] = 0
return t
}