forked from ebhomengo/niki
1
0
Fork 0
niki/vendor/golang.org/x/sys/unix/ioctl_zos.go

119 lines
2.1 KiB
Go
Raw Normal View History

2024-02-18 10:42:21 +00:00
// Copyright 2020 The Go Authors. All rights reserved.
2024-02-18 10:42:21 +00:00
// Use of this source code is governed by a BSD-style
2024-02-18 10:42:21 +00:00
// license that can be found in the LICENSE file.
//go:build zos && s390x
package unix
import (
"runtime"
"unsafe"
)
// ioctl itself should not be exposed directly, but additional get/set
2024-02-18 10:42:21 +00:00
// functions for specific types are permissible.
// IoctlSetInt performs an ioctl operation which sets an integer value
2024-02-18 10:42:21 +00:00
// on fd, using the specified request number.
2024-02-18 10:42:21 +00:00
func IoctlSetInt(fd int, req int, value int) error {
2024-02-18 10:42:21 +00:00
return ioctl(fd, req, uintptr(value))
2024-02-18 10:42:21 +00:00
}
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
2024-02-18 10:42:21 +00:00
//
2024-02-18 10:42:21 +00:00
// To change fd's window size, the req argument should be TIOCSWINSZ.
2024-02-18 10:42:21 +00:00
func IoctlSetWinsize(fd int, req int, value *Winsize) error {
2024-02-18 10:42:21 +00:00
// TODO: if we get the chance, remove the req parameter and
2024-02-18 10:42:21 +00:00
// hardcode TIOCSWINSZ.
2024-02-18 10:42:21 +00:00
return ioctlPtr(fd, req, unsafe.Pointer(value))
2024-02-18 10:42:21 +00:00
}
// IoctlSetTermios performs an ioctl on fd with a *Termios.
2024-02-18 10:42:21 +00:00
//
2024-02-18 10:42:21 +00:00
// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
2024-02-18 10:42:21 +00:00
func IoctlSetTermios(fd int, req int, value *Termios) error {
2024-02-18 10:42:21 +00:00
if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
2024-02-18 10:42:21 +00:00
return ENOSYS
2024-02-18 10:42:21 +00:00
}
2024-02-18 10:42:21 +00:00
err := Tcsetattr(fd, int(req), value)
2024-02-18 10:42:21 +00:00
runtime.KeepAlive(value)
2024-02-18 10:42:21 +00:00
return err
2024-02-18 10:42:21 +00:00
}
// IoctlGetInt performs an ioctl operation which gets an integer value
2024-02-18 10:42:21 +00:00
// from fd, using the specified request number.
2024-02-18 10:42:21 +00:00
//
2024-02-18 10:42:21 +00:00
// A few ioctl requests use the return value as an output parameter;
2024-02-18 10:42:21 +00:00
// for those, IoctlRetInt should be used instead of this function.
2024-02-18 10:42:21 +00:00
func IoctlGetInt(fd int, req int) (int, error) {
2024-02-18 10:42:21 +00:00
var value int
2024-02-18 10:42:21 +00:00
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
2024-02-18 10:42:21 +00:00
return value, err
2024-02-18 10:42:21 +00:00
}
func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
2024-02-18 10:42:21 +00:00
var value Winsize
2024-02-18 10:42:21 +00:00
err := ioctlPtr(fd, req, unsafe.Pointer(&value))
2024-02-18 10:42:21 +00:00
return &value, err
2024-02-18 10:42:21 +00:00
}
// IoctlGetTermios performs an ioctl on fd with a *Termios.
2024-02-18 10:42:21 +00:00
//
2024-02-18 10:42:21 +00:00
// The req value is expected to be TCGETS
2024-02-18 10:42:21 +00:00
func IoctlGetTermios(fd int, req int) (*Termios, error) {
2024-02-18 10:42:21 +00:00
var value Termios
2024-02-18 10:42:21 +00:00
if req != TCGETS {
2024-02-18 10:42:21 +00:00
return &value, ENOSYS
2024-02-18 10:42:21 +00:00
}
2024-02-18 10:42:21 +00:00
err := Tcgetattr(fd, &value)
2024-02-18 10:42:21 +00:00
return &value, err
2024-02-18 10:42:21 +00:00
}