aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/unix2syscall_freebsd.go
diff options
context:
space:
mode:
authorAnkush Patel2026-02-05 14:42:40 +1300
committerAnkush Patel2026-02-14 03:32:14 +1300
commit903fc9d077a81d9224de4207d1672c0b1127cf42 (patch)
tree05ae39d5ebbe41bb64d41d7e0f03df7dac596dae /internal/syscallcompat/unix2syscall_freebsd.go
parent3191c18f67346c95e4dbdfd16b44256ddfe20b4f (diff)
Added basic support for FreeBSD.
Diffstat (limited to 'internal/syscallcompat/unix2syscall_freebsd.go')
-rw-r--r--internal/syscallcompat/unix2syscall_freebsd.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/syscallcompat/unix2syscall_freebsd.go b/internal/syscallcompat/unix2syscall_freebsd.go
new file mode 100644
index 0000000..fe85cf6
--- /dev/null
+++ b/internal/syscallcompat/unix2syscall_freebsd.go
@@ -0,0 +1,28 @@
+package syscallcompat
+
+import (
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+// Unix2syscall converts a unix.Stat_t struct to a syscall.Stat_t struct.
+// A direct cast does not work because the padding is named differently in
+// unix.Stat_t for some reason ("X__unused" in syscall, "_" in unix).
+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.NsecToTimespec(unix.TimespecToNsec(u.Atim)),
+ Mtimespec: syscall.NsecToTimespec(unix.TimespecToNsec(u.Mtim)),
+ Ctimespec: syscall.NsecToTimespec(unix.TimespecToNsec(u.Ctim)),
+ }
+}