aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/emulate.go
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-14 02:35:46 +0100
committerrfjakob2019-01-14 21:27:28 +0100
commit42bf6d1c68700a0d5d910c1be42088cc14125fec (patch)
treeccaaefec84822df3547ee8a33f7dc84b5518b6b6 /internal/syscallcompat/emulate.go
parentda557702d713e38a8c6c4c28275724c70988f919 (diff)
syscallcompat: Drop Renameat emulation on macOS.
Diffstat (limited to 'internal/syscallcompat/emulate.go')
-rw-r--r--internal/syscallcompat/emulate.go46
1 files changed, 0 insertions, 46 deletions
diff --git a/internal/syscallcompat/emulate.go b/internal/syscallcompat/emulate.go
index 35e17c6..7fea3a8 100644
--- a/internal/syscallcompat/emulate.go
+++ b/internal/syscallcompat/emulate.go
@@ -11,34 +11,6 @@ import (
var chdirMutex sync.Mutex
-// emulateRenameat emulates the syscall for platforms that don't have it
-// in the kernel (darwin).
-func emulateRenameat(olddirfd int, oldpath string, newdirfd int, newpath string) error {
- chdirMutex.Lock()
- defer chdirMutex.Unlock()
- // Unless both paths are absolute we have to save the old working dir and
- // Chdir(oldWd) back to it in the end. If we error out before the first
- // chdir, Chdir(oldWd) is unneccassary but does no harm.
- if !filepath.IsAbs(oldpath) || !filepath.IsAbs(newpath) {
- oldWd, err := os.Getwd()
- if err != nil {
- return err
- }
- defer os.Chdir(oldWd)
- }
- // Make oldpath absolute
- oldpath, err := dirfdAbs(olddirfd, oldpath)
- if err != nil {
- return err
- }
- // Make newpath absolute
- newpath, err = dirfdAbs(newdirfd, newpath)
- if err != nil {
- return err
- }
- return syscall.Rename(oldpath, newpath)
-}
-
// emulateUnlinkat emulates the syscall for platforms that don't have it
// in the kernel (darwin).
func emulateUnlinkat(dirfd int, path string, flags int) (err error) {
@@ -82,24 +54,6 @@ func emulateMknodat(dirfd int, path string, mode uint32, dev int) error {
return syscall.Mknod(path, mode, dev)
}
-// dirfdAbs transforms the dirfd-relative "path" to an absolute one. If the
-// path is not already absolute, this function will change the working
-// directory. The caller has to chdir back.
-func dirfdAbs(dirfd int, path string) (string, error) {
- if filepath.IsAbs(path) {
- return path, nil
- }
- err := syscall.Fchdir(dirfd)
- if err != nil {
- return "", err
- }
- wd, err := os.Getwd()
- if err != nil {
- return "", err
- }
- return filepath.Join(wd, path), nil
-}
-
// emulateFchmodat emulates the syscall for platforms that don't have it
// in the kernel (darwin).
func emulateFchmodat(dirfd int, path string, mode uint32, flags int) (err error) {