Quellcode durchsuchen

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 <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Tobias Klauser vor 8 Jahren
Ursprung
Commit
4ed4d404df
1 geänderte Dateien mit 10 neuen und 0 gelöschten Zeilen
  1. 10 0
      unix/syscall_linux.go

+ 10 - 0
unix/syscall_linux.go

@@ -61,6 +61,10 @@ func IoctlSetInt(fd int, req uint, value int) (err error) {
 	return ioctl(fd, req, uintptr(value))
 	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
 // IoctlGetInt performs an ioctl operation which gets an integer value
 // from fd, using the specified request number.
 // from fd, using the specified request number.
 func IoctlGetInt(fd int, req uint) (int, error) {
 func IoctlGetInt(fd int, req uint) (int, error) {
@@ -69,6 +73,12 @@ func IoctlGetInt(fd int, req uint) (int, error) {
 	return value, err
 	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)
 //sys	Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
 
 
 func Link(oldpath string, newpath string) (err error) {
 func Link(oldpath string, newpath string) (err error) {