mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update vendor for kr/pty
Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes <guillaume.charmes@docker.com> (github: creack)
This commit is contained in:
parent
bb43761940
commit
802407a099
3 changed files with 85 additions and 0 deletions
5
vendor/src/github.com/kr/pty/doc.go
vendored
5
vendor/src/github.com/kr/pty/doc.go
vendored
|
@ -2,9 +2,14 @@
|
|||
package pty
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
// ErrUnsupported is returned if a function is not
|
||||
// available on the current platform.
|
||||
var ErrUnsupported = errors.New("unsupported")
|
||||
|
||||
// Opens a pty and its corresponding tty.
|
||||
func Open() (pty, tty *os.File, err error) {
|
||||
return open()
|
||||
|
|
53
vendor/src/github.com/kr/pty/pty_freebsd.go
vendored
Normal file
53
vendor/src/github.com/kr/pty/pty_freebsd.go
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
package pty
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
sys_TIOCGPTN = 0x4004740F
|
||||
sys_TIOCSPTLCK = 0x40045431
|
||||
)
|
||||
|
||||
func open() (pty, tty *os.File, err error) {
|
||||
p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
sname, err := ptsname(p)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return p, t, nil
|
||||
}
|
||||
|
||||
func ptsname(f *os.File) (string, error) {
|
||||
var n int
|
||||
err := ioctl(f.Fd(), sys_TIOCGPTN, &n)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "/dev/pts/" + strconv.Itoa(n), nil
|
||||
}
|
||||
|
||||
func ioctl(fd uintptr, cmd uintptr, data *int) error {
|
||||
_, _, e := syscall.Syscall(
|
||||
syscall.SYS_IOCTL,
|
||||
fd,
|
||||
cmd,
|
||||
uintptr(unsafe.Pointer(data)),
|
||||
)
|
||||
if e != 0 {
|
||||
return syscall.ENOTTY
|
||||
}
|
||||
return nil
|
||||
}
|
27
vendor/src/github.com/kr/pty/pty_unsupported.go
vendored
Normal file
27
vendor/src/github.com/kr/pty/pty_unsupported.go
vendored
Normal file
|
@ -0,0 +1,27 @@
|
|||
// +build !linux,!darwin,!freebsd
|
||||
|
||||
package pty
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func open() (pty, tty *os.File, err error) {
|
||||
return nil, nil, ErrUnsupported
|
||||
}
|
||||
|
||||
func ptsname(f *os.File) (string, error) {
|
||||
return "", ErrUnsupported
|
||||
}
|
||||
|
||||
func grantpt(f *os.File) error {
|
||||
return ErrUnsupported
|
||||
}
|
||||
|
||||
func unlockpt(f *os.File) error {
|
||||
return ErrUnsupported
|
||||
}
|
||||
|
||||
func ioctl(fd, cmd, ptr uintptr) error {
|
||||
return ErrUnsupported
|
||||
}
|
Loading…
Reference in a new issue