1// Copyright 2009,2010 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 5package syscall 6 7import ( 8 "sync" 9 "unsafe" 10) 11 12const ( 13 _SYS_FSTAT_FREEBSD12 = 551 // { int fstat(int fd, _Out_ struct stat *sb); } 14 _SYS_FSTATAT_FREEBSD12 = 552 // { int fstatat(int fd, _In_z_ char *path, \ 15 _SYS_GETDIRENTRIES_FREEBSD12 = 554 // { ssize_t getdirentries(int fd, \ 16 _SYS_STATFS_FREEBSD12 = 555 // { int statfs(_In_z_ char *path, \ 17 _SYS_FSTATFS_FREEBSD12 = 556 // { int fstatfs(int fd, \ 18 _SYS_GETFSSTAT_FREEBSD12 = 557 // { int getfsstat( \ 19 _SYS_MKNODAT_FREEBSD12 = 559 // { int mknodat(int fd, _In_z_ char *path, \ 20) 21 22// See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html. 23var ( 24 osreldateOnce sync.Once 25 osreldate uint32 26) 27 28// INO64_FIRST from /usr/src/lib/libc/sys/compat-ino64.h 29const _ino64First = 1200031 30 31func supportsABI(ver uint32) bool { 32 osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") }) 33 return osreldate >= ver 34} 35 36func direntIno(buf []byte) (uint64, bool) { 37 return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno)) 38} 39 40func direntReclen(buf []byte) (uint64, bool) { 41 return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen)) 42} 43 44func direntNamlen(buf []byte) (uint64, bool) { 45 return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) 46} 47