From 4fa21dcb57c5a0b7761bfec606ffd0e94c293ce8 Mon Sep 17 00:00:00 2001 From: Ankush Patel Date: Thu, 5 Feb 2026 14:42:40 +1300 Subject: Added basic support for FreeBSD. Freebsd-support: Change bash shebang to use /usr/bin/env Freebsd-support: Fix go vet "undefined" fixes when running make ci freebsd: stub xattr functions /proc/PID/fd does not exist on freebsd. freebsd-support: modify FchmodatNofollow for FreeBSD FreeBSD supports the Fchmodat system call, with the AT_SYMLINK_NOFOLLOW flag. FchmodatNofollow has been modified to use this system call and flag. freebsd-support: PR changes and fixes * Functions in fusefrontend_reverse/node_xattr_freebsd.go have been stubbed for now. * asuser_freebsd.go updated to only run f() when context is nil; otherwise log a warning and return an error. * emulate.go build flags updated, and FreeBSD specific version added. * sys_freebsd.go bug in Renameat2 with RENAME_EXCHANGE flag fixed. FreeBSD does not support atomic file swapping, so this flag now returns an error. * unix2syscall and atime is identical between FreeBSD and Darwin, updated filenames so Go will build the file for FreeBSD and Mac OS. freebsd-support: Addressed more PR comments and fixed build tags --- tests/canonical-benchmarks.bash | 3 ++- tests/dl-linux-tarball.bash | 4 +++- tests/fuse-unmount.bash | 5 ++++- tests/matrix/atime_darwin+freebsd.go | 11 +++++++++++ tests/matrix/atime_darwin.go | 9 --------- tests/reverse/linux-tarball-test.bash | 2 +- tests/sshfs-benchmark.bash | 2 +- tests/stress_tests/extractloop.bash | 2 +- tests/stress_tests/fsstress-gocryptfs.bash | 2 +- tests/stress_tests/pingpong.bash | 2 +- 10 files changed, 25 insertions(+), 17 deletions(-) create mode 100644 tests/matrix/atime_darwin+freebsd.go delete mode 100644 tests/matrix/atime_darwin.go (limited to 'tests') diff --git a/tests/canonical-benchmarks.bash b/tests/canonical-benchmarks.bash index 4c1a357..963fd6a 100755 --- a/tests/canonical-benchmarks.bash +++ b/tests/canonical-benchmarks.bash @@ -1,4 +1,4 @@ -#!/bin/bash -eu +#!/usr/bin/env bash # # Run the set of "canonical" benchmarks that are shown on # https://nuetzlich.net/gocryptfs/comparison/ @@ -6,6 +6,7 @@ # # This is called by the top-level script "benchmark.bash". +set -eu MYNAME=$(basename "$0") diff --git a/tests/dl-linux-tarball.bash b/tests/dl-linux-tarball.bash index 03c0e7d..3c325db 100755 --- a/tests/dl-linux-tarball.bash +++ b/tests/dl-linux-tarball.bash @@ -1,8 +1,10 @@ -#!/bin/bash -eu +#!/usr/bin/env bash # # This script checks the size of /tmp/linux-3.0.tar.gz and downloads # a fresh copy if the size is incorrect or the file is missing. +set -eu + URL=https://cdn.kernel.org/pub/linux/kernel/v3.0/linux-3.0.tar.gz TGZ=/tmp/linux-3.0.tar.gz diff --git a/tests/fuse-unmount.bash b/tests/fuse-unmount.bash index b36f28c..02c6e4c 100755 --- a/tests/fuse-unmount.bash +++ b/tests/fuse-unmount.bash @@ -1,10 +1,13 @@ -#!/bin/bash -eu +#!/usr/bin/env bash # # Compatibility wrapper around "fusermount" on Linux and "umount" on # Mac OS X and friends. # # This script can be sourced or executed directly. # + +set -eu + fuse-unmount() { local MYNAME=$(basename "$BASH_SOURCE") if [[ $# -eq 0 ]] ; then diff --git a/tests/matrix/atime_darwin+freebsd.go b/tests/matrix/atime_darwin+freebsd.go new file mode 100644 index 0000000..43db0d5 --- /dev/null +++ b/tests/matrix/atime_darwin+freebsd.go @@ -0,0 +1,11 @@ +//go:build darwin || freebsd + +package matrix + +import ( + "syscall" +) + +func extractAtimeMtime(st syscall.Stat_t) [2]syscall.Timespec { + return [2]syscall.Timespec{st.Atimespec, st.Mtimespec} +} diff --git a/tests/matrix/atime_darwin.go b/tests/matrix/atime_darwin.go deleted file mode 100644 index 5f89c69..0000000 --- a/tests/matrix/atime_darwin.go +++ /dev/null @@ -1,9 +0,0 @@ -package matrix - -import ( - "syscall" -) - -func extractAtimeMtime(st syscall.Stat_t) [2]syscall.Timespec { - return [2]syscall.Timespec{st.Atimespec, st.Mtimespec} -} diff --git a/tests/reverse/linux-tarball-test.bash b/tests/reverse/linux-tarball-test.bash index 4054c29..27afa23 100755 --- a/tests/reverse/linux-tarball-test.bash +++ b/tests/reverse/linux-tarball-test.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu diff --git a/tests/sshfs-benchmark.bash b/tests/sshfs-benchmark.bash index 4695f8d..2421f20 100755 --- a/tests/sshfs-benchmark.bash +++ b/tests/sshfs-benchmark.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash set -eu diff --git a/tests/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash index 1f78a5e..714d2d7 100755 --- a/tests/stress_tests/extractloop.bash +++ b/tests/stress_tests/extractloop.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Mount a gocryptfs filesystem somewhere on /tmp, then run two parallel # infinite loops inside that do the following: diff --git a/tests/stress_tests/fsstress-gocryptfs.bash b/tests/stress_tests/fsstress-gocryptfs.bash index e6c3281..7e3f160 100755 --- a/tests/stress_tests/fsstress-gocryptfs.bash +++ b/tests/stress_tests/fsstress-gocryptfs.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Mount a gocryptfs filesystem in /var/tmp and run fsstress against it # in an infinite loop, only exiting on errors. diff --git a/tests/stress_tests/pingpong.bash b/tests/stress_tests/pingpong.bash index d0d21b3..4fd5ff2 100755 --- a/tests/stress_tests/pingpong.bash +++ b/tests/stress_tests/pingpong.bash @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # Mounts two gocryptfs filesystems, "ping" and "pong" and moves the # linux-3.0 kernel tree back and forth between them, checking integrity -- cgit v1.2.3