Merge pull request #3985 from creack/add_freebsd_support
Add freebsd client support
This commit is contained in:
commit
8bcb156694
8 changed files with 217 additions and 2 deletions
|
@ -68,7 +68,7 @@ ENV GOPATH /go:/go/src/github.com/dotcloud/docker/vendor
|
|||
RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1
|
||||
|
||||
# Compile Go for cross compilation
|
||||
ENV DOCKER_CROSSPLATFORMS linux/386 linux/arm darwin/amd64 darwin/386
|
||||
ENV DOCKER_CROSSPLATFORMS linux/386 linux/arm darwin/amd64 darwin/386 freebsd/amd64 freebsd/386 freebsd/arm
|
||||
# (set an explicit GOARM of 5 for maximum compatibility)
|
||||
ENV GOARM 5
|
||||
RUN cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done'
|
||||
|
|
21
archive/stat_unsupported.go
Normal file
21
archive/stat_unsupported.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
// +build !linux !amd64
|
||||
|
||||
package archive
|
||||
|
||||
import "syscall"
|
||||
|
||||
func getLastAccess(stat *syscall.Stat_t) syscall.Timespec {
|
||||
return syscall.Timespec{}
|
||||
}
|
||||
|
||||
func getLastModification(stat *syscall.Stat_t) syscall.Timespec {
|
||||
return syscall.Timespec{}
|
||||
}
|
||||
|
||||
func LUtimesNano(path string, ts []syscall.Timespec) error {
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func UtimesNano(path string, ts []syscall.Timespec) error {
|
||||
return ErrNotImplemented
|
||||
}
|
|
@ -39,7 +39,7 @@ clone() {
|
|||
echo done
|
||||
}
|
||||
|
||||
clone git github.com/kr/pty 3b1f6487b
|
||||
clone git github.com/kr/pty 98c7b80083
|
||||
|
||||
clone git github.com/gorilla/context 708054d61e5
|
||||
|
||||
|
|
67
pkg/term/termios_freebsd.go
Normal file
67
pkg/term/termios_freebsd.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package term
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
getTermios = syscall.TIOCGETA
|
||||
setTermios = syscall.TIOCSETA
|
||||
|
||||
IGNBRK = syscall.IGNBRK
|
||||
PARMRK = syscall.PARMRK
|
||||
INLCR = syscall.INLCR
|
||||
IGNCR = syscall.IGNCR
|
||||
ECHONL = syscall.ECHONL
|
||||
CSIZE = syscall.CSIZE
|
||||
ICRNL = syscall.ICRNL
|
||||
ISTRIP = syscall.ISTRIP
|
||||
PARENB = syscall.PARENB
|
||||
ECHO = syscall.ECHO
|
||||
ICANON = syscall.ICANON
|
||||
ISIG = syscall.ISIG
|
||||
IXON = syscall.IXON
|
||||
BRKINT = syscall.BRKINT
|
||||
INPCK = syscall.INPCK
|
||||
OPOST = syscall.OPOST
|
||||
CS8 = syscall.CS8
|
||||
IEXTEN = syscall.IEXTEN
|
||||
)
|
||||
|
||||
type Termios struct {
|
||||
Iflag uint32
|
||||
Oflag uint32
|
||||
Cflag uint32
|
||||
Lflag uint32
|
||||
Cc [20]byte
|
||||
Ispeed uint32
|
||||
Ospeed uint32
|
||||
}
|
||||
|
||||
// MakeRaw put the terminal connected to the given file descriptor into raw
|
||||
// mode and returns the previous state of the terminal so that it can be
|
||||
// restored.
|
||||
func MakeRaw(fd uintptr) (*State, error) {
|
||||
var oldState State
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
// C.makeraw()
|
||||
// return &oldState, nil
|
||||
|
||||
newState := oldState.termios
|
||||
newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)
|
||||
newState.Oflag &^= OPOST
|
||||
newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN)
|
||||
newState.Cflag &^= (CSIZE | PARENB)
|
||||
newState.Cflag |= CS8
|
||||
newState.Cc[syscall.VMIN] = 1
|
||||
newState.Cc[syscall.VTIME] = 0
|
||||
|
||||
if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &oldState, nil
|
||||
}
|
42
utils/signal_freebsd.go
Normal file
42
utils/signal_freebsd.go
Normal file
|
@ -0,0 +1,42 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func CatchAll(sigc chan os.Signal) {
|
||||
signal.Notify(sigc,
|
||||
syscall.SIGABRT,
|
||||
syscall.SIGALRM,
|
||||
syscall.SIGBUS,
|
||||
syscall.SIGCHLD,
|
||||
syscall.SIGCONT,
|
||||
syscall.SIGFPE,
|
||||
syscall.SIGHUP,
|
||||
syscall.SIGILL,
|
||||
syscall.SIGINT,
|
||||
syscall.SIGIO,
|
||||
syscall.SIGIOT,
|
||||
syscall.SIGKILL,
|
||||
syscall.SIGPIPE,
|
||||
syscall.SIGPROF,
|
||||
syscall.SIGQUIT,
|
||||
syscall.SIGSEGV,
|
||||
syscall.SIGSTOP,
|
||||
syscall.SIGSYS,
|
||||
syscall.SIGTERM,
|
||||
syscall.SIGTRAP,
|
||||
syscall.SIGTSTP,
|
||||
syscall.SIGTTIN,
|
||||
syscall.SIGTTOU,
|
||||
syscall.SIGURG,
|
||||
syscall.SIGUSR1,
|
||||
syscall.SIGUSR2,
|
||||
syscall.SIGVTALRM,
|
||||
syscall.SIGWINCH,
|
||||
syscall.SIGXCPU,
|
||||
syscall.SIGXFSZ,
|
||||
)
|
||||
}
|
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