gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ioctl_zos.go (2101B)


      1 // Copyright 2020 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 //go:build zos && s390x
      6 // +build zos,s390x
      7 
      8 package unix
      9 
     10 import (
     11 	"runtime"
     12 	"unsafe"
     13 )
     14 
     15 // ioctl itself should not be exposed directly, but additional get/set
     16 // functions for specific types are permissible.
     17 
     18 // IoctlSetInt performs an ioctl operation which sets an integer value
     19 // on fd, using the specified request number.
     20 func IoctlSetInt(fd int, req int, value int) error {
     21 	return ioctl(fd, req, uintptr(value))
     22 }
     23 
     24 // IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
     25 //
     26 // To change fd's window size, the req argument should be TIOCSWINSZ.
     27 func IoctlSetWinsize(fd int, req int, value *Winsize) error {
     28 	// TODO: if we get the chance, remove the req parameter and
     29 	// hardcode TIOCSWINSZ.
     30 	return ioctlPtr(fd, req, unsafe.Pointer(value))
     31 }
     32 
     33 // IoctlSetTermios performs an ioctl on fd with a *Termios.
     34 //
     35 // The req value is expected to be TCSETS, TCSETSW, or TCSETSF
     36 func IoctlSetTermios(fd int, req int, value *Termios) error {
     37 	if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
     38 		return ENOSYS
     39 	}
     40 	err := Tcsetattr(fd, int(req), value)
     41 	runtime.KeepAlive(value)
     42 	return err
     43 }
     44 
     45 // IoctlGetInt performs an ioctl operation which gets an integer value
     46 // from fd, using the specified request number.
     47 //
     48 // A few ioctl requests use the return value as an output parameter;
     49 // for those, IoctlRetInt should be used instead of this function.
     50 func IoctlGetInt(fd int, req int) (int, error) {
     51 	var value int
     52 	err := ioctlPtr(fd, req, unsafe.Pointer(&value))
     53 	return value, err
     54 }
     55 
     56 func IoctlGetWinsize(fd int, req int) (*Winsize, error) {
     57 	var value Winsize
     58 	err := ioctlPtr(fd, req, unsafe.Pointer(&value))
     59 	return &value, err
     60 }
     61 
     62 // IoctlGetTermios performs an ioctl on fd with a *Termios.
     63 //
     64 // The req value is expected to be TCGETS
     65 func IoctlGetTermios(fd int, req int) (*Termios, error) {
     66 	var value Termios
     67 	if req != TCGETS {
     68 		return &value, ENOSYS
     69 	}
     70 	err := Tcgetattr(fd, &value)
     71 	return &value, err
     72 }