|
|
@@ -6,7 +6,19 @@
|
|
|
|
|
|
package unix
|
|
|
|
|
|
-import "runtime"
|
|
|
+import (
|
|
|
+ "runtime"
|
|
|
+ "unsafe"
|
|
|
+)
|
|
|
+
|
|
|
+// ioctl itself should not be exposed directly, but additional get/set
|
|
|
+// functions for specific types are permissible.
|
|
|
+
|
|
|
+// IoctlSetInt performs an ioctl operation which sets an integer value
|
|
|
+// on fd, using the specified request number.
|
|
|
+func IoctlSetInt(fd int, req uint, value int) error {
|
|
|
+ return ioctl(fd, req, uintptr(value))
|
|
|
+}
|
|
|
|
|
|
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
|
|
//
|
|
|
@@ -14,7 +26,7 @@ import "runtime"
|
|
|
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
|
|
// TODO: if we get the chance, remove the req parameter and
|
|
|
// hardcode TIOCSWINSZ.
|
|
|
- err := ioctlSetWinsize(fd, req, value)
|
|
|
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
|
|
runtime.KeepAlive(value)
|
|
|
return err
|
|
|
}
|
|
|
@@ -24,7 +36,27 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
|
|
// The req value will usually be TCSETA or TIOCSETA.
|
|
|
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
|
|
// TODO: if we get the chance, remove the req parameter.
|
|
|
- err := ioctlSetTermios(fd, req, value)
|
|
|
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
|
|
runtime.KeepAlive(value)
|
|
|
return err
|
|
|
}
|
|
|
+
|
|
|
+// 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) {
|
|
|
+ var value int
|
|
|
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
|
+ return value, err
|
|
|
+}
|
|
|
+
|
|
|
+func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
|
|
+ var value Winsize
|
|
|
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
|
|
+ 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
|
|
|
+}
|