tc_freebsd_nocgo.go 1.6 KB

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