diff --git a/unix/syscall_openbsd.go b/unix/syscall_openbsd.go index 21581967..a90d8fbc 100644 --- a/unix/syscall_openbsd.go +++ b/unix/syscall_openbsd.go @@ -107,6 +107,45 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { return ENOSYS } +//sys ioctl(fd int, req uint, arg uintptr) (err error) + +// ioctl itself should not be exposed directly, but additional get/set +// functions for specific types are permissible. + +// IoctlSetInt performs an ioctl operation which sets an integer value +// on fd, using the specified request number. +func IoctlSetInt(fd int, req uint, value int) error { + return ioctl(fd, req, uintptr(value)) +} + +func IoctlSetWinsize(fd int, req uint, value *Winsize) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +func IoctlSetTermios(fd int, req uint, value *Termios) error { + return ioctl(fd, req, uintptr(unsafe.Pointer(value))) +} + +// IoctlGetInt performs an ioctl operation which gets an integer value +// from fd, using the specified request number. +func IoctlGetInt(fd int, req uint) (int, error) { + var value int + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return value, err +} + +func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { + var value Winsize + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + +func IoctlGetTermios(fd int, req uint) (*Termios, error) { + var value Termios + err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) + return &value, err +} + /* * Exposed directly */ @@ -227,7 +266,6 @@ func setattrlistTimes(path string, times []Timespec, flags int) error { // getresuid // getrtable // getthrid -// ioctl // ktrace // lfs_bmapv // lfs_markv diff --git a/unix/types_openbsd.go b/unix/types_openbsd.go index 44ea7c02..837b514d 100644 --- a/unix/types_openbsd.go +++ b/unix/types_openbsd.go @@ -244,6 +244,8 @@ type BpfTimeval C.struct_bpf_timeval type Termios C.struct_termios +type Winsize C.struct_winsize + // fchmodat-like syscalls. const ( diff --git a/unix/zsyscall_openbsd_386.go b/unix/zsyscall_openbsd_386.go index f48beb09..3b55544d 100644 --- a/unix/zsyscall_openbsd_386.go +++ b/unix/zsyscall_openbsd_386.go @@ -404,6 +404,16 @@ func getdents(fd int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/unix/zsyscall_openbsd_amd64.go b/unix/zsyscall_openbsd_amd64.go index 44a3faf7..cdaf4ef4 100644 --- a/unix/zsyscall_openbsd_amd64.go +++ b/unix/zsyscall_openbsd_amd64.go @@ -404,6 +404,16 @@ func getdents(fd int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/unix/zsyscall_openbsd_arm.go b/unix/zsyscall_openbsd_arm.go index 1563752d..6c4dc8a9 100644 --- a/unix/zsyscall_openbsd_arm.go +++ b/unix/zsyscall_openbsd_arm.go @@ -404,6 +404,16 @@ func getdents(fd int, buf []byte) (n int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func ioctl(fd int, req uint, arg uintptr) (err error) { + _, _, e1 := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(arg)) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Access(path string, mode uint32) (err error) { var _p0 *byte _p0, err = BytePtrFromString(path) diff --git a/unix/ztypes_openbsd_386.go b/unix/ztypes_openbsd_386.go index af295c3d..2cf08bf4 100644 --- a/unix/ztypes_openbsd_386.go +++ b/unix/ztypes_openbsd_386.go @@ -440,6 +440,13 @@ type Termios struct { Ospeed int32 } +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + const ( AT_FDCWD = -0x64 AT_SYMLINK_NOFOLLOW = 0x2 diff --git a/unix/ztypes_openbsd_amd64.go b/unix/ztypes_openbsd_amd64.go index ae153e70..7cfc61f6 100644 --- a/unix/ztypes_openbsd_amd64.go +++ b/unix/ztypes_openbsd_amd64.go @@ -447,6 +447,13 @@ type Termios struct { Ospeed int32 } +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + const ( AT_FDCWD = -0x64 AT_SYMLINK_NOFOLLOW = 0x2 diff --git a/unix/ztypes_openbsd_arm.go b/unix/ztypes_openbsd_arm.go index 35bb6195..842c59c5 100644 --- a/unix/ztypes_openbsd_arm.go +++ b/unix/ztypes_openbsd_arm.go @@ -433,6 +433,13 @@ type Termios struct { Ospeed int32 } +type Winsize struct { + Row uint16 + Col uint16 + Xpixel uint16 + Ypixel uint16 +} + const ( AT_FDCWD = -0x64 AT_SYMLINK_NOFOLLOW = 0x2