1
2
3
4
5
6
7
8 package unix
9
10 import (
11 "runtime"
12 "unsafe"
13 )
14
15
16
17
18
19
20 func IoctlSetInt(fd int, req uint, value int) error {
21 return ioctl(fd, req, uintptr(value))
22 }
23
24
25
26
27 func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
28
29
30 err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
31 runtime.KeepAlive(value)
32 return err
33 }
34
35
36
37
38 func IoctlSetTermios(fd int, req uint, value *Termios) error {
39 if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
40 return ENOSYS
41 }
42 err := Tcsetattr(fd, int(req), value)
43 runtime.KeepAlive(value)
44 return err
45 }
46
47
48
49
50
51
52 func IoctlGetInt(fd int, req uint) (int, error) {
53 var value int
54 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
55 return value, err
56 }
57
58 func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
59 var value Winsize
60 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
61 return &value, err
62 }
63
64
65
66
67 func IoctlGetTermios(fd int, req uint) (*Termios, error) {
68 var value Termios
69 if req != TCGETS {
70 return &value, ENOSYS
71 }
72 err := Tcgetattr(fd, &value)
73 return &value, err
74 }
75
View as plain text