diff options
| author | Zach Riggle <zachriggle@users.noreply.github.com> | 2017-06-26 08:32:38 -0500 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-06-26 15:32:38 +0200 |
| commit | 2420edb02ee04fc1b7dc39e7d5e17f98e3e3a24b (patch) | |
| tree | 80d02d9248808642724208e809a43062636250b4 /vm/vmimpl | |
| parent | dd93f0378ab9dcfd951394cb53514bfdee67b4d9 (diff) | |
Port console to Darwin (#253)
* Port console to Darwin
* Get syz-executor to build correctly
* Do not export unix and syscall constants
* Add presubmit test
* Add myself to contributors
Diffstat (limited to 'vm/vmimpl')
| -rw-r--r-- | vm/vmimpl/console.go | 6 | ||||
| -rw-r--r-- | vm/vmimpl/darwin.go | 15 | ||||
| -rw-r--r-- | vm/vmimpl/linux.go | 18 |
3 files changed, 36 insertions, 3 deletions
diff --git a/vm/vmimpl/console.go b/vm/vmimpl/console.go index f4a0b71d1..3fa501162 100644 --- a/vm/vmimpl/console.go +++ b/vm/vmimpl/console.go @@ -29,11 +29,11 @@ func OpenConsole(con string) (rc io.ReadCloser, err error) { } }() var term unix.Termios - if _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), unix.TCGETS2, uintptr(unsafe.Pointer(&term))); errno != 0 { + if _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscall_TCGETS, uintptr(unsafe.Pointer(&term))); errno != 0 { return nil, fmt.Errorf("failed to get console termios: %v", errno) } // no parity bit, only need 1 stop bit, no hardware flowcontrol - term.Cflag &^= unix.CBAUD | unix.CSIZE | unix.PARENB | unix.CSTOPB | unix.CRTSCTS + term.Cflag &^= unix_CBAUD | unix.CSIZE | unix.PARENB | unix.CSTOPB | unix_CRTSCTS // ignore modem controls term.Cflag |= unix.B115200 | unix.CS8 | unix.CLOCAL | unix.CREAD // setup for non-canonical mode @@ -42,7 +42,7 @@ func OpenConsole(con string) (rc io.ReadCloser, err error) { term.Oflag &^= unix.OPOST term.Cc[unix.VMIN] = 0 term.Cc[unix.VTIME] = 10 // 1 second timeout - if _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), unix.TCSETS2, uintptr(unsafe.Pointer(&term))); errno != 0 { + if _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscall_TCSETS, uintptr(unsafe.Pointer(&term))); errno != 0 { return nil, fmt.Errorf("failed to get console termios: %v", errno) } tmp := fd diff --git a/vm/vmimpl/darwin.go b/vm/vmimpl/darwin.go new file mode 100644 index 000000000..87efdd881 --- /dev/null +++ b/vm/vmimpl/darwin.go @@ -0,0 +1,15 @@ +// Copyright 2017 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// +build darwin + +package vmimpl + +import "syscall" + +const ( + unix_CBAUD = 0 + unix_CRTSCTS = 0 + syscall_TCGETS = syscall.TIOCGETA + syscall_TCSETS = syscall.TIOCSETA +) diff --git a/vm/vmimpl/linux.go b/vm/vmimpl/linux.go new file mode 100644 index 000000000..d25b263fc --- /dev/null +++ b/vm/vmimpl/linux.go @@ -0,0 +1,18 @@ +// Copyright 2017 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +// +build linux + +package vmimpl + +import ( + "syscall" + "unix" +) + +const ( + unix_CBAUD = unix.CBAUD + unix_CRTSCTS = unix.CRTSCTS + syscall_TCGETS = syscall.TCGETS + syscall_TCSETS = syscall.TCSETS +) |
