aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat/emulate.go
diff options
context:
space:
mode:
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) {