2023-04-26 20:20:43 -04:00
|
|
|
//go:build solaris
|
|
|
|
// +build solaris
|
|
|
|
|
2019-07-29 19:43:22 -04:00
|
|
|
package pty
|
|
|
|
|
|
|
|
import (
|
2023-04-26 20:20:43 -04:00
|
|
|
"syscall"
|
2019-07-29 19:43:22 -04:00
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
2023-04-26 20:20:43 -04:00
|
|
|
//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
|
|
|
|
//go:linkname procioctl libc_ioctl
|
|
|
|
var procioctl uintptr
|
|
|
|
|
2019-07-29 19:43:22 -04:00
|
|
|
const (
|
|
|
|
// see /usr/include/sys/stropts.h
|
2023-04-26 20:20:43 -04:00
|
|
|
I_PUSH = uintptr((int32('S')<<8 | 002))
|
|
|
|
I_STR = uintptr((int32('S')<<8 | 010))
|
|
|
|
I_FIND = uintptr((int32('S')<<8 | 013))
|
|
|
|
|
2019-07-29 19:43:22 -04:00
|
|
|
// see /usr/include/sys/ptms.h
|
|
|
|
ISPTM = (int32('P') << 8) | 1
|
|
|
|
UNLKPT = (int32('P') << 8) | 2
|
|
|
|
PTSSTTY = (int32('P') << 8) | 3
|
|
|
|
ZONEPT = (int32('P') << 8) | 4
|
|
|
|
OWNERPT = (int32('P') << 8) | 5
|
2023-04-26 20:20:43 -04:00
|
|
|
|
|
|
|
// see /usr/include/sys/termios.h
|
|
|
|
TIOCSWINSZ = (uint32('T') << 8) | 103
|
|
|
|
TIOCGWINSZ = (uint32('T') << 8) | 104
|
2019-07-29 19:43:22 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
type strioctl struct {
|
2023-04-26 20:20:43 -04:00
|
|
|
icCmd int32
|
|
|
|
icTimeout int32
|
|
|
|
icLen int32
|
|
|
|
icDP unsafe.Pointer
|
2019-07-29 19:43:22 -04:00
|
|
|
}
|
|
|
|
|
2023-04-26 20:20:43 -04:00
|
|
|
// Defined in asm_solaris_amd64.s.
|
|
|
|
func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
|
|
|
|
2019-07-29 19:43:22 -04:00
|
|
|
func ioctl(fd, cmd, ptr uintptr) error {
|
2023-04-26 20:20:43 -04:00
|
|
|
if _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procioctl)), 3, fd, cmd, ptr, 0, 0, 0); errno != 0 {
|
|
|
|
return errno
|
|
|
|
}
|
|
|
|
return nil
|
2019-07-29 19:43:22 -04:00
|
|
|
}
|