comparison vendor/golang.org/x/sys/unix/ioctl_zos.go @ 66:787b5ee0289d draft

Use vendored modules Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author yakumo.izuru
date Sun, 23 Jul 2023 13:18:53 +0000
parents
children
comparison
equal deleted inserted replaced
65:6d985efa0f7a 66:787b5ee0289d
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 uint, 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 uint, value *Winsize) error {
28 // TODO: if we get the chance, remove the req parameter and
29 // hardcode TIOCSWINSZ.
30 err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
31 runtime.KeepAlive(value)
32 return err
33 }
34
35 // IoctlSetTermios performs an ioctl on fd with a *Termios.
36 //
37 // The req value is expected to be TCSETS, TCSETSW, or TCSETSF
38 func IoctlSetTermios(fd int, req uint, value *Termios) error {
39 if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
40 return ENOSYS
41 }
42 err := Tcsetattr(fd, int(req), value)
43 runtime.KeepAlive(value)
44 return err
45 }
46
47 // IoctlGetInt performs an ioctl operation which gets an integer value
48 // from fd, using the specified request number.
49 //
50 // A few ioctl requests use the return value as an output parameter;
51 // for those, IoctlRetInt should be used instead of this function.
52 func IoctlGetInt(fd int, req uint) (int, error) {
53 var value int
54 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
55 return value, err
56 }
57
58 func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
59 var value Winsize
60 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
61 return &value, err
62 }
63
64 // IoctlGetTermios performs an ioctl on fd with a *Termios.
65 //
66 // The req value is expected to be TCGETS
67 func IoctlGetTermios(fd int, req uint) (*Termios, error) {
68 var value Termios
69 if req != TCGETS {
70 return &value, ENOSYS
71 }
72 err := Tcgetattr(fd, &value)
73 return &value, err
74 }