No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

75 líneas
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 uint, 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 uint, value *Winsize) error {
  22. // TODO: if we get the chance, remove the req parameter and
  23. // hardcode TIOCSWINSZ.
  24. err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
  25. runtime.KeepAlive(value)
  26. return err
  27. }
  28. // IoctlSetTermios performs an ioctl on fd with a *Termios.
  29. //
  30. // The req value is expected to be TCSETS, TCSETSW, or TCSETSF
  31. func IoctlSetTermios(fd int, req uint, value *Termios) error {
  32. if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) {
  33. return ENOSYS
  34. }
  35. err := Tcsetattr(fd, int(req), value)
  36. runtime.KeepAlive(value)
  37. return err
  38. }
  39. // IoctlGetInt performs an ioctl operation which gets an integer value
  40. // from fd, using the specified request number.
  41. //
  42. // A few ioctl requests use the return value as an output parameter;
  43. // for those, IoctlRetInt should be used instead of this function.
  44. func IoctlGetInt(fd int, req uint) (int, error) {
  45. var value int
  46. err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
  47. return value, err
  48. }
  49. func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
  50. var value Winsize
  51. err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
  52. return &value, err
  53. }
  54. // IoctlGetTermios performs an ioctl on fd with a *Termios.
  55. //
  56. // The req value is expected to be TCGETS
  57. func IoctlGetTermios(fd int, req uint) (*Termios, error) {
  58. var value Termios
  59. if req != TCGETS {
  60. return &value, ENOSYS
  61. }
  62. err := Tcgetattr(fd, &value)
  63. return &value, err
  64. }