install go2rtc on bob
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
# IOCTL
|
||||
|
||||
This is just an example how Linux IOCTL constants works.
|
||||
@@ -0,0 +1,28 @@
|
||||
package ioctl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func Str(b []byte) string {
|
||||
if i := bytes.IndexByte(b, 0); i >= 0 {
|
||||
return string(b[:i])
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func io(mode byte, type_ byte, number byte, size uint16) uintptr {
|
||||
return uintptr(mode)<<30 | uintptr(size)<<16 | uintptr(type_)<<8 | uintptr(number)
|
||||
}
|
||||
|
||||
func IOR(type_ byte, number byte, size uint16) uintptr {
|
||||
return io(read, type_, number, size)
|
||||
}
|
||||
|
||||
func IOW(type_ byte, number byte, size uint16) uintptr {
|
||||
return io(write, type_, number, size)
|
||||
}
|
||||
|
||||
func IORW(type_ byte, number byte, size uint16) uintptr {
|
||||
return io(read|write, type_, number, size)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build arm || arm64 || 386 || amd64
|
||||
|
||||
package ioctl
|
||||
|
||||
const (
|
||||
write = 1
|
||||
read = 2
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
//go:build mipsle
|
||||
|
||||
package ioctl
|
||||
|
||||
const (
|
||||
read = 1
|
||||
write = 2
|
||||
)
|
||||
@@ -0,0 +1,14 @@
|
||||
package ioctl
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func Ioctl(fd int, req uint, arg unsafe.Pointer) error {
|
||||
_, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg))
|
||||
if err != 0 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package ioctl
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestIOR(t *testing.T) {
|
||||
// #define SNDRV_PCM_IOCTL_INFO _IOR('A', 0x01, struct snd_pcm_info)
|
||||
if runtime.GOARCH == "arm64" {
|
||||
c := IOR('A', 0x01, 288)
|
||||
require.Equal(t, uintptr(0x81204101), c)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user