summaryrefslogtreecommitdiff
path: root/internal/syscallcompat/emulate.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/syscallcompat/emulate.go')
-rw-r--r--internal/syscallcompat/emulate.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/syscallcompat/emulate.go b/internal/syscallcompat/emulate.go
index 96776e2..e5aeae7 100644
--- a/internal/syscallcompat/emulate.go
+++ b/internal/syscallcompat/emulate.go
@@ -210,3 +210,23 @@ func emulateMkdirat(dirfd int, path string, mode uint32) (err error) {
}
return syscall.Mkdir(path, mode)
}
+
+// emulateFstatat emulates the syscall for platforms that don't have it
+// in the kernel (darwin).
+func emulateFstatat(dirfd int, path string, stat *unix.Stat_t, flags int) (err error) {
+ if !filepath.IsAbs(path) {
+ chdirMutex.Lock()
+ defer chdirMutex.Unlock()
+ cwd, err := syscall.Open(".", syscall.O_RDONLY, 0)
+ if err != nil {
+ return err
+ }
+ defer syscall.Close(cwd)
+ err = syscall.Fchdir(dirfd)
+ if err != nil {
+ return err
+ }
+ defer syscall.Fchdir(cwd)
+ }
+ return unix.Lstat(path, stat)
+}