1
// Copyright 2020 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
15
// ioctl itself should not be exposed directly, but additional get/set
16
// functions for specific types are permissible.
18
// IoctlSetInt performs an ioctl operation which sets an integer value
19
// on fd, using the specified request number.
20
func IoctlSetInt(fd int, req int, value int) error {
21
return ioctl(fd, req, uintptr(value))
24
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
26
// To change fd's window size, the req argument should be TIOCSWINSZ.
27
func IoctlSetWinsize(fd int, req int, value *Winsize) error {
28
// TODO: if we get the chance, remove the req parameter and
29
// hardcode TIOCSWINSZ.
30
return ioctlPtr(fd, req, unsafe.Pointer(value))
33
// IoctlSetTermios performs an ioctl on fd with a *Termios.
35
// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
36
func IoctlSetTermios(fd int, req int, value *Termios) error {
37
if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
40
err := Tcsetattr(fd, int(req), value)
41
runtime.KeepAlive(value)
45
// IoctlGetInt performs an ioctl operation which gets an integer value
46
// from fd, using the specified request number.
48
// A few ioctl requests use the return value as an output parameter;
49
// for those, IoctlRetInt should be used instead of this function.
50
func IoctlGetInt(fd int, req int) (int, error) {
52
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
56
func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
58
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
62
// IoctlGetTermios performs an ioctl on fd with a *Termios.
64
// The req value is expected to be TCGETS
65
func IoctlGetTermios(fd int, req int) (*Termios, error) {
70
err := Tcgetattr(fd, &value)