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