From 2420edb02ee04fc1b7dc39e7d5e17f98e3e3a24b Mon Sep 17 00:00:00 2001 From: Zach Riggle Date: Mon, 26 Jun 2017 08:32:38 -0500 Subject: 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 --- vm/vmimpl/console.go | 6 +++--- vm/vmimpl/darwin.go | 15 +++++++++++++++ vm/vmimpl/linux.go | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 vm/vmimpl/darwin.go create mode 100644 vm/vmimpl/linux.go (limited to 'vm/vmimpl') 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 +) -- cgit mrf-deployment