• Yuval Pavel Zholkover's avatar
    unix: FreeBSD 12 ino64 support · 5535b4e6
    Yuval Pavel Zholkover authored
    Background:
    The 64-bit inode project was merged into the upcoming FreeBSD 12 release.
    It changes the ABI for structs holding inodes: stat, statfs, dirent.
    New system call numbers were introduced which accept the new struct layouts,
    the old ones were marked as COMPAT11.
    Their equivalent libc wrappers are using ELF symbol versioning.
    The new wrappers have moved from @FBSD_1.0 to @FBSD_1.5.
    
    Backward and forward compatability is achieved by always using the new struct
    layouts while converting the old struct instance to the new layout on old kernels.
    https://svnweb.freebsd.org/base?view=revision&revision=318736
    https://svnweb.freebsd.org/base?view=revision&revision=320278
    
    The same approach is used for Go:
    The new Stat_t, Statfs_t and Dirent types hold 64-bit inodes and additional ABI
    changes, they are generated from their C definitions in FreeBSD-12 using cgo -godefs.
    Each type has an unexported *_freebsd11 counterpart generated the same way.
    Previous directly exposed syscalls like Fstat have now a wrapper in place calling
    either fstat or fstat_freebsd12 zsyscall wrapper based on the kern.osreldate.
    If an old syscall needs to be used, then the returned *_freebsd11 result is converted
    to the new layout before returning from the wrapper.
    
    Introduce supportsABI() call to check the kern.osreldate sysctl for the ABI version.
    Drop the old struct stat8 definition in favour of the <sys/stat.h> version.
    Run the mktypes part of GOOS=freebsd GOARCH={386,amd64,arm} ./mkall.sh
    on FreeBSD-12.0-ALPHA6 (r338675), updating all types except Kevent.
    
    Expose Mknodat, both COMPAT11 version (currently missing) and the FreeBSD 12 one.
    Some COMPAT11 syscalls have no direct FreeBSD 12 counterpart, in those cases
    an *at(AT_FDCWD, ...) is used instead.
    
    Updates golang/go#22448
    
    Change-Id: I87940b88ae358db88103cdcd06f9cafbf4694cfc
    Reviewed-on: https://go-review.googlesource.com/c/136816
    Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarGiovanni Bajo <rasky@develer.com>
    Reviewed-by: 's avatarTobias Klauser <tobias.klauser@gmail.com>
    5535b4e6
zsyscall_freebsd_386.go 48.2 KB