aboutsummaryrefslogtreecommitdiffstats
path: root/vm/vmimpl
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-15 19:11:49 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-15 19:34:30 +0200
commit18d7d030e5660609a142ba7a2ea55d5e72fd23a2 (patch)
tree8f63ff0392423a34f5698861fd6dec1f5d5ce88d /vm/vmimpl
parenta2267789b8c3045ee299c40439ab74034b111ef1 (diff)
vm/vmimpl: update console code for the new unix package
The current code is now broken on darwin: syzkaller$ GOOS=darwin go install ./vm/... vm/vmimpl/console.go:30:33: undefined: unix.SYS_IOCTL vm/vmimpl/console.go:45:32: undefined: unix.SYS_IOCTL
Diffstat (limited to 'vm/vmimpl')
-rw-r--r--vm/vmimpl/console.go13
1 files changed, 5 insertions, 8 deletions
diff --git a/vm/vmimpl/console.go b/vm/vmimpl/console.go
index 74449cab4..8688a0b52 100644
--- a/vm/vmimpl/console.go
+++ b/vm/vmimpl/console.go
@@ -9,7 +9,6 @@ import (
"os/exec"
"sync"
"syscall"
- "unsafe"
"github.com/google/syzkaller/pkg/osutil"
"golang.org/x/sys/unix"
@@ -26,10 +25,9 @@ func OpenConsole(con string) (rc io.ReadCloser, err error) {
syscall.Close(fd)
}
}()
- var term unix.Termios
- _, _, errno := syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscallTCGETS, uintptr(unsafe.Pointer(&term)))
- if errno != 0 {
- return nil, fmt.Errorf("failed to get console termios: %v", errno)
+ term, err := unix.IoctlGetTermios(fd, syscallTCGETS)
+ if err != nil {
+ return nil, fmt.Errorf("failed to get console termios: %v", err)
}
// No parity bit, only need 1 stop bit, no hardware flowcontrol,
term.Cflag &^= unixCBAUD | unix.CSIZE | unix.PARENB | unix.CSTOPB | unixCRTSCTS
@@ -42,9 +40,8 @@ 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
- _, _, errno = syscall.Syscall(unix.SYS_IOCTL, uintptr(fd), syscallTCSETS, uintptr(unsafe.Pointer(&term)))
- if errno != 0 {
- return nil, fmt.Errorf("failed to get console termios: %v", errno)
+ if err = unix.IoctlSetTermios(fd, syscallTCSETS, term); err != nil {
+ return nil, fmt.Errorf("failed to get console termios: %v", err)
}
tmp := fd
fd = -1