tc_freebsd_nocgo.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //go:build freebsd && !cgo
  2. // +build freebsd,!cgo
  3. /*
  4. Copyright The containerd Authors.
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. */
  15. package console
  16. import (
  17. "fmt"
  18. "os"
  19. "golang.org/x/sys/unix"
  20. )
  21. const (
  22. cmdTcGet = unix.TIOCGETA
  23. cmdTcSet = unix.TIOCSETA
  24. )
  25. //
  26. // Implementing the functions below requires cgo support. Non-cgo stubs
  27. // versions are defined below to enable cross-compilation of source code
  28. // that depends on these functions, but the resultant cross-compiled
  29. // binaries cannot actually be used. If the stub function(s) below are
  30. // actually invoked they will display an error message and cause the
  31. // calling process to exit.
  32. //
  33. // unlockpt unlocks the slave pseudoterminal device corresponding to the master pseudoterminal referred to by f.
  34. // unlockpt should be called before opening the slave side of a pty.
  35. func unlockpt(f *os.File) error {
  36. panic("unlockpt() support requires cgo.")
  37. }
  38. // ptsname retrieves the name of the first available pts for the given master.
  39. func ptsname(f *os.File) (string, error) {
  40. n, err := unix.IoctlGetInt(int(f.Fd()), unix.TIOCGPTN)
  41. if err != nil {
  42. return "", err
  43. }
  44. return fmt.Sprintf("/dev/pts/%d", n), nil
  45. }