aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/unix2syscall.go
diff options
context:
space:
mode:
authorAnkush Patel2026-02-05 14:42:40 +1300
committerJakob Unterwurzacher2026-03-08 21:35:59 +0100
commit4fa21dcb57c5a0b7761bfec606ffd0e94c293ce8 (patch)
treebac9fd670706e64f1624183b1ba946d4b966bb19 /internal/syscallcompat/unix2syscall.go
parent7bf3a3edf6ce940abf42054daa09de8e8cf9d083 (diff)
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
Diffstat (limited to 'internal/syscallcompat/unix2syscall.go')
-rw-r--r--internal/syscallcompat/unix2syscall.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/syscallcompat/unix2syscall.go b/internal/syscallcompat/unix2syscall.go
new file mode 100644
index 0000000..fa2e8c4
--- /dev/null
+++ b/internal/syscallcompat/unix2syscall.go
@@ -0,0 +1,28 @@
+//go:build darwin || freebsd
+
+package syscallcompat
+
+import (
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+// Unix2syscall converts a unix.Stat_t struct to a syscall.Stat_t struct.
+func Unix2syscall(u unix.Stat_t) syscall.Stat_t {
+ return syscall.Stat_t{
+ Dev: u.Dev,
+ Ino: u.Ino,
+ Nlink: u.Nlink,
+ Mode: u.Mode,
+ Uid: u.Uid,
+ Gid: u.Gid,
+ Rdev: u.Rdev,
+ Size: u.Size,
+ Blksize: u.Blksize,
+ Blocks: u.Blocks,
+ Atimespec: syscall.Timespec(u.Atim),
+ Mtimespec: syscall.Timespec(u.Mtim),
+ Ctimespec: syscall.Timespec(u.Ctim),
+ }
+}