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