You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 lines
2.1 KiB

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