From 4ed4d404df456f81e878683a0363ed3013a59003 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 30 Jun 2017 15:23:30 +0200 Subject: [PATCH] unix: add ioctl functions for termios on Linux Add IoctlGetTermios and IoctlGetTermios to retreive and manipulate Termios structures on Linux, akin to the already existing implementation or Solaris. If desired, functions conforming to POSIX tcgetattr/tcsetattr could be implemented on top of these. Change-Id: I2a71061bad2e632c597b6f6184ad6374c46a43ee Reviewed-on: https://go-review.googlesource.com/47330 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- unix/syscall_linux.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 886e4140..cc618f7c 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -61,6 +61,10 @@ func IoctlSetInt(fd int, req uint, value int) (err error) { return ioctl(fd, req, uintptr(value)) } +func IoctlSetTermios(fd int, req uint, value *Termios) (err error) { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + // IoctlGetInt performs an ioctl operation which gets an integer value // from fd, using the specified request number. func IoctlGetInt(fd int, req uint) (int, error) { @@ -69,6 +73,12 @@ func IoctlGetInt(fd int, req uint) (int, error) { return value, err } +func IoctlGetTermios(fd int, req uint) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + //sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) func Link(oldpath string, newpath string) (err error) {