Skip to content

Commit aff023c

Browse files
committed
Uprev docker/docker/pkg/term and runc/libcontainer
Signed-off-by: Amit Krishnan <krish.amit@gmail.com>
1 parent c0a78ae commit aff023c

File tree

11 files changed

+180
-28
lines changed

11 files changed

+180
-28
lines changed

hack/vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ clone git github.com/cloudfoundry/gosigar 3ed7c74352dae6dc00bdc8c74045375352e3ec
99
clone git github.com/codegangsta/cli 9fec0fad02befc9209347cc6d620e68e1b45f74d
1010
clone git github.com/coreos/go-systemd 7b2428fec40033549c68f54e26e89e7ca9a9ce31
1111
clone git github.com/cyberdelia/go-metrics-graphite 7e54b5c2aa6eaff4286c44129c3def899dff528c
12-
clone git github.com/docker/docker f3dcc1c46249ffc4a73ab2005d1ad011dff3c7df
12+
clone git github.com/docker/docker 2f6e3b0ba027b558adabd41344fee59db4441011
1313
clone git github.com/docker/go-units 5d2041e26a699eaca682e2ea41c8f891e1060444
1414
clone git github.com/godbus/dbus e2cf28118e66a6a63db46cf6088a35d2054d3bb0
1515
clone git github.com/golang/glog 23def4e6c14b4da8ac2ed8007337bc5eb5007998

vendor/src/github.com/docker/docker/pkg/term/tc_linux_cgo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
import "C"
1212

1313
// Termios is the Unix API for terminal I/O.
14-
// It is passthgrouh for syscall.Termios in order to make it portable with
14+
// It is passthrough for syscall.Termios in order to make it portable with
1515
// other platforms where it is not available or handled differently.
1616
type Termios syscall.Termios
1717

vendor/src/github.com/docker/docker/pkg/term/tc_other.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// +build !windows
22
// +build !linux !cgo
3+
// +build !solaris !cgo
34

45
package term
56

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// +build solaris,cgo
2+
3+
package term
4+
5+
import (
6+
"syscall"
7+
"unsafe"
8+
)
9+
10+
// #include <termios.h>
11+
import "C"
12+
13+
// Termios is the Unix API for terminal I/O.
14+
// It is passthrough for syscall.Termios in order to make it portable with
15+
// other platforms where it is not available or handled differently.
16+
type Termios syscall.Termios
17+
18+
// MakeRaw put the terminal connected to the given file descriptor into raw
19+
// mode and returns the previous state of the terminal so that it can be
20+
// restored.
21+
func MakeRaw(fd uintptr) (*State, error) {
22+
var oldState State
23+
if err := tcget(fd, &oldState.termios); err != 0 {
24+
return nil, err
25+
}
26+
27+
newState := oldState.termios
28+
29+
newState.Iflag &^= (syscall.IGNBRK | syscall.BRKINT | syscall.PARMRK | syscall.ISTRIP | syscall.INLCR | syscall.IGNCR | syscall.ICRNL | syscall.IXON | syscall.IXANY)
30+
newState.Oflag &^= syscall.OPOST
31+
newState.Lflag &^= (syscall.ECHO | syscall.ECHONL | syscall.ICANON | syscall.ISIG | syscall.IEXTEN)
32+
newState.Cflag &^= (syscall.CSIZE | syscall.PARENB)
33+
newState.Cflag |= syscall.CS8
34+
35+
/*
36+
VMIN is the minimum number of characters that needs to be read in non-canonical mode for it to be returned
37+
Since VMIN is overloaded with another element in canonical mode when we switch modes it defaults to 4. It
38+
needs to be explicitly set to 1.
39+
*/
40+
newState.Cc[C.VMIN] = 1
41+
newState.Cc[C.VTIME] = 0
42+
43+
if err := tcset(fd, &newState); err != 0 {
44+
return nil, err
45+
}
46+
return &oldState, nil
47+
}
48+
49+
func tcget(fd uintptr, p *Termios) syscall.Errno {
50+
ret, err := C.tcgetattr(C.int(fd), (*C.struct_termios)(unsafe.Pointer(p)))
51+
if ret != 0 {
52+
return err.(syscall.Errno)
53+
}
54+
return 0
55+
}
56+
57+
func tcset(fd uintptr, p *Termios) syscall.Errno {
58+
ret, err := C.tcsetattr(C.int(fd), C.TCSANOW, (*C.struct_termios)(unsafe.Pointer(p)))
59+
if ret != 0 {
60+
return err.(syscall.Errno)
61+
}
62+
return 0
63+
}

vendor/src/github.com/docker/docker/pkg/term/term.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"os"
1111
"os/signal"
1212
"syscall"
13-
"unsafe"
1413
)
1514

1615
var (
@@ -27,6 +26,8 @@ type State struct {
2726
type Winsize struct {
2827
Height uint16
2928
Width uint16
29+
x uint16
30+
y uint16
3031
}
3132

3233
// StdStreams returns the standard streams (stdin, stdout, stedrr).
@@ -45,27 +46,6 @@ func GetFdInfo(in interface{}) (uintptr, bool) {
4546
return inFd, isTerminalIn
4647
}
4748

48-
// GetWinsize returns the window size based on the specified file descriptor.
49-
func GetWinsize(fd uintptr) (*Winsize, error) {
50-
ws := &Winsize{}
51-
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws)))
52-
// Skip errno = 0
53-
if err == 0 {
54-
return ws, nil
55-
}
56-
return ws, err
57-
}
58-
59-
// SetWinsize tries to set the specified window size for the specified file descriptor.
60-
func SetWinsize(fd uintptr, ws *Winsize) error {
61-
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws)))
62-
// Skip errno = 0
63-
if err == 0 {
64-
return nil
65-
}
66-
return err
67-
}
68-
6949
// IsTerminal returns true if the given file descriptor is a terminal.
7050
func IsTerminal(fd uintptr) bool {
7151
var termios Termios
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// +build solaris
2+
3+
package term
4+
5+
import (
6+
"syscall"
7+
"unsafe"
8+
)
9+
10+
/*
11+
#include <unistd.h>
12+
#include <stropts.h>
13+
#include <termios.h>
14+
15+
// Small wrapper to get rid of variadic args of ioctl()
16+
int my_ioctl(int fd, int cmd, struct winsize *ws) {
17+
return ioctl(fd, cmd, ws);
18+
}
19+
*/
20+
import "C"
21+
22+
// GetWinsize returns the window size based on the specified file descriptor.
23+
func GetWinsize(fd uintptr) (*Winsize, error) {
24+
ws := &Winsize{}
25+
ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCGWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
26+
// Skip retval = 0
27+
if ret == 0 {
28+
return ws, nil
29+
}
30+
return ws, err
31+
}
32+
33+
// SetWinsize tries to set the specified window size for the specified file descriptor.
34+
func SetWinsize(fd uintptr, ws *Winsize) error {
35+
ret, err := C.my_ioctl(C.int(fd), C.int(syscall.TIOCSWINSZ), (*C.struct_winsize)(unsafe.Pointer(ws)))
36+
// Skip retval = 0
37+
if ret == 0 {
38+
return nil
39+
}
40+
return err
41+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// +build !solaris,!windows
2+
3+
package term
4+
5+
import (
6+
"syscall"
7+
"unsafe"
8+
)
9+
10+
// GetWinsize returns the window size based on the specified file descriptor.
11+
func GetWinsize(fd uintptr) (*Winsize, error) {
12+
ws := &Winsize{}
13+
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(ws)))
14+
// Skipp errno = 0
15+
if err == 0 {
16+
return ws, nil
17+
}
18+
return ws, err
19+
}
20+
21+
// SetWinsize tries to set the specified window size for the specified file descriptor.
22+
func SetWinsize(fd uintptr, ws *Winsize) error {
23+
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(syscall.TIOCSWINSZ), uintptr(unsafe.Pointer(ws)))
24+
// Skipp errno = 0
25+
if err == 0 {
26+
return nil
27+
}
28+
return err
29+
}

vendor/src/github.com/docker/docker/pkg/term/windows/ansi_reader.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ func readInputEvents(fd uintptr, maxBytes int) ([]winterm.INPUT_RECORD, error) {
136136

137137
// KeyEvent Translation Helpers
138138

139-
var arrowKeyMapPrefix = map[winterm.WORD]string{
139+
var arrowKeyMapPrefix = map[uint16]string{
140140
winterm.VK_UP: "%s%sA",
141141
winterm.VK_DOWN: "%s%sB",
142142
winterm.VK_RIGHT: "%s%sC",
143143
winterm.VK_LEFT: "%s%sD",
144144
}
145145

146-
var keyMapPrefix = map[winterm.WORD]string{
146+
var keyMapPrefix = map[uint16]string{
147147
winterm.VK_UP: "\x1B[%sA",
148148
winterm.VK_DOWN: "\x1B[%sB",
149149
winterm.VK_RIGHT: "\x1B[%sC",
@@ -207,7 +207,7 @@ func keyToString(keyEvent *winterm.KEY_EVENT_RECORD, escapeSequence []byte) stri
207207
}
208208

209209
// formatVirtualKey converts a virtual key (e.g., up arrow) into the appropriate ANSI string.
210-
func formatVirtualKey(key winterm.WORD, controlState winterm.DWORD, escapeSequence []byte) string {
210+
func formatVirtualKey(key uint16, controlState uint32, escapeSequence []byte) string {
211211
shift, alt, control := getControlKeys(controlState)
212212
modifier := getControlKeysModifier(shift, alt, control)
213213

@@ -223,7 +223,7 @@ func formatVirtualKey(key winterm.WORD, controlState winterm.DWORD, escapeSequen
223223
}
224224

225225
// getControlKeys extracts the shift, alt, and ctrl key states.
226-
func getControlKeys(controlState winterm.DWORD) (shift, alt, control bool) {
226+
func getControlKeys(controlState uint32) (shift, alt, control bool) {
227227
shift = 0 != (controlState & winterm.SHIFT_PRESSED)
228228
alt = 0 != (controlState & (winterm.LEFT_ALT_PRESSED | winterm.RIGHT_ALT_PRESSED))
229229
control = 0 != (controlState & (winterm.LEFT_CTRL_PRESSED | winterm.RIGHT_CTRL_PRESSED))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package libcontainer
2+
3+
import (
4+
"errors"
5+
)
6+
7+
// NewConsole returns an initalized console that can be used within a container by copying bytes
8+
// from the master side to the slave that is attached as the tty for the container's init process.
9+
func NewConsole(uid, gid int) (Console, error) {
10+
return nil, errors.New("libcontainer console is not supported on Solaris")
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package libcontainer
2+
3+
// State represents a running container's state
4+
type State struct {
5+
BaseState
6+
7+
// Platform specific fields below here
8+
}
9+
10+
// A libcontainer container object.
11+
//
12+
// Each container is thread-safe within the same process. Since a container can
13+
// be destroyed by a separate process, any function may return that the container
14+
// was not found.
15+
type Container interface {
16+
BaseContainer
17+
18+
// Methods below here are platform specific
19+
20+
}

0 commit comments

Comments
 (0)