-
Notifications
You must be signed in to change notification settings - Fork 0
/
ioctl_linux.go
42 lines (33 loc) · 996 Bytes
/
ioctl_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package pty
// from <asm-generic/ioctl.h>
const (
_IOC_NRBITS = 8
_IOC_TYPEBITS = 8
_IOC_SIZEBITS = 14
_IOC_DIRBITS = 2
_IOC_NRSHIFT = 0
_IOC_TYPESHIFT = _IOC_NRSHIFT + _IOC_NRBITS
_IOC_SIZESHIFT = _IOC_TYPESHIFT + _IOC_TYPEBITS
_IOC_DIRSHIFT = _IOC_SIZESHIFT + _IOC_SIZEBITS
_IOC_NONE uint = 0
_IOC_WRITE uint = 1
_IOC_READ uint = 2
)
func _IOC(dir uint, ioctl_type byte, nr byte, size uintptr) uintptr {
return (uintptr(dir)<<_IOC_DIRSHIFT |
uintptr(ioctl_type)<<_IOC_TYPESHIFT |
uintptr(nr)<<_IOC_NRSHIFT |
size<<_IOC_SIZESHIFT)
}
func _IO(ioctl_type byte, nr byte) uintptr {
return _IOC(_IOC_NONE, ioctl_type, nr, 0)
}
func _IOR(ioctl_type byte, nr byte, size uintptr) uintptr {
return _IOC(_IOC_READ, ioctl_type, nr, size)
}
func _IOW(ioctl_type byte, nr byte, size uintptr) uintptr {
return _IOC(_IOC_WRITE, ioctl_type, nr, size)
}
func _IOWR(ioctl_type byte, nr byte, size uintptr) uintptr {
return _IOC(_IOC_READ|_IOC_WRITE, ioctl_type, nr, size)
}