aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/sys_darwin.go
diff options
context:
space:
mode:
authorSebastian Lackner2017-11-28 00:54:38 +0100
committerrfjakob2017-11-28 09:28:06 +0100
commit5a56810603ff9608c98d71cbfb8a6454da4c2261 (patch)
tree1011a0161c3df932cfd072e3c7e19d72e983724d /internal/syscallcompat/sys_darwin.go
parent295c4c2b852c83ff265466cdeba3cbbc05820e4a (diff)
fusefrontend: Use the Symlinkat syscall for longname handling
Diffstat (limited to 'internal/syscallcompat/sys_darwin.go')
-rw-r--r--internal/syscallcompat/sys_darwin.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go
index 5504860..4068e1a 100644
--- a/internal/syscallcompat/sys_darwin.go
+++ b/internal/syscallcompat/sys_darwin.go
@@ -148,3 +148,20 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
defer syscall.Fchdir(cwd)
return syscall.Lchown(path, uid, gid)
}
+
+// Poor man's Symlinkat.
+func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
+ 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(newdirfd)
+ if err != nil {
+ return err
+ }
+ defer syscall.Fchdir(cwd)
+ return syscall.Symlink(oldpath, newpath)
+}