syscall_dragonfly.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2009 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. package syscall
  5. import (
  6. "sync"
  7. "unsafe"
  8. )
  9. const _SYS_DUP3 = 0
  10. // See version list in https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/param.h
  11. var (
  12. osreldateOnce sync.Once
  13. osreldate uint32
  14. )
  15. // First __DragonFly_version after September 2019 ABI changes
  16. // http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html
  17. const _dragonflyABIChangeVersion = 500705
  18. func supportsABI(ver uint32) bool {
  19. osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") })
  20. return osreldate >= ver
  21. }
  22. func direntIno(buf []byte) (uint64, bool) {
  23. return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
  24. }
  25. func direntReclen(buf []byte) (uint64, bool) {
  26. namlen, ok := direntNamlen(buf)
  27. if !ok {
  28. return 0, false
  29. }
  30. return (16 + namlen + 1 + 7) &^ 7, true
  31. }
  32. func direntNamlen(buf []byte) (uint64, bool) {
  33. return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
  34. }