summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/syscallcompat/emulate.go20
-rw-r--r--internal/syscallcompat/emulate_test.go26
-rw-r--r--internal/syscallcompat/sys_common.go5
-rw-r--r--internal/syscallcompat/sys_common_test.go26
-rw-r--r--internal/syscallcompat/sys_darwin.go4
-rw-r--r--internal/syscallcompat/sys_linux.go5
6 files changed, 31 insertions, 55 deletions
diff --git a/internal/syscallcompat/emulate.go b/internal/syscallcompat/emulate.go
index a98a0ce..7bed31a 100644
--- a/internal/syscallcompat/emulate.go
+++ b/internal/syscallcompat/emulate.go
@@ -30,26 +30,6 @@ func emulateMknodat(dirfd int, path string, mode uint32, dev int) error {
return syscall.Mknod(path, mode, dev)
}
-// emulateMkdirat emulates the syscall for platforms that don't have it
-// in the kernel (darwin).
-func emulateMkdirat(dirfd int, path string, mode uint32) (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 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) {
diff --git a/internal/syscallcompat/emulate_test.go b/internal/syscallcompat/emulate_test.go
index 6db37f8..eeffebf 100644
--- a/internal/syscallcompat/emulate_test.go
+++ b/internal/syscallcompat/emulate_test.go
@@ -27,32 +27,6 @@ func TestEmulateMknodat(t *testing.T) {
}
}
-func TestEmulateMkdirat(t *testing.T) {
- err := emulateMkdirat(tmpDirFd, "mkdirat", 0700)
- if err != nil {
- t.Fatal(err)
- }
- fi, err := os.Stat(tmpDir + "/mkdirat")
- if err != nil {
- t.Fatal(err)
- }
- if !fi.IsDir() {
- t.Fatalf("mkdirat did not create a directory")
- }
- // Test with absolute path
- err = emulateMkdirat(-1, tmpDir+"/mkdirat2", 0700)
- if err != nil {
- t.Fatal(err)
- }
- fi, err = os.Stat(tmpDir + "/mkdirat2")
- if err != nil {
- t.Fatal(err)
- }
- if !fi.IsDir() {
- t.Fatalf("mkdirat did not create a directory")
- }
-}
-
func TestEmulateFstatat(t *testing.T) {
var st unix.Stat_t
// stat a normal file (size 3)
diff --git a/internal/syscallcompat/sys_common.go b/internal/syscallcompat/sys_common.go
index 21bac56..577e2ed 100644
--- a/internal/syscallcompat/sys_common.go
+++ b/internal/syscallcompat/sys_common.go
@@ -92,6 +92,11 @@ func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
return unix.Symlinkat(oldpath, newdirfd, newpath)
}
+// Mkdirat syscall.
+func Mkdirat(dirfd int, path string, mode uint32) (err error) {
+ return unix.Mkdirat(dirfd, path, mode)
+}
+
const XATTR_SIZE_MAX = 65536
// Make the buffer 1kB bigger so we can detect overflows
diff --git a/internal/syscallcompat/sys_common_test.go b/internal/syscallcompat/sys_common_test.go
index 78283e6..e1c7b24 100644
--- a/internal/syscallcompat/sys_common_test.go
+++ b/internal/syscallcompat/sys_common_test.go
@@ -247,3 +247,29 @@ func TestSymlinkat(t *testing.T) {
}
symlinkCheckMode(t, st)
}
+
+func TestMkdirat(t *testing.T) {
+ err := Mkdirat(tmpDirFd, "mkdirat", 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fi, err := os.Stat(tmpDir + "/mkdirat")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !fi.IsDir() {
+ t.Fatalf("mkdirat did not create a directory")
+ }
+ // Test with absolute path
+ err = Mkdirat(-1, tmpDir+"/mkdirat2", 0700)
+ if err != nil {
+ t.Fatal(err)
+ }
+ fi, err = os.Stat(tmpDir + "/mkdirat2")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !fi.IsDir() {
+ t.Fatalf("mkdirat did not create a directory")
+ }
+}
diff --git a/internal/syscallcompat/sys_darwin.go b/internal/syscallcompat/sys_darwin.go
index 2780ef6..3b27560 100644
--- a/internal/syscallcompat/sys_darwin.go
+++ b/internal/syscallcompat/sys_darwin.go
@@ -117,10 +117,6 @@ func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.C
return Symlinkat(oldpath, newdirfd, newpath)
}
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- return emulateMkdirat(dirfd, path, mode)
-}
-
func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error) {
if context != nil {
runtime.LockOSThread()
diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go
index 0b34aa1..21e07c9 100644
--- a/internal/syscallcompat/sys_linux.go
+++ b/internal/syscallcompat/sys_linux.go
@@ -176,11 +176,6 @@ func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.C
return Symlinkat(oldpath, newdirfd, newpath)
}
-// Mkdirat syscall.
-func Mkdirat(dirfd int, path string, mode uint32) (err error) {
- return syscall.Mkdirat(dirfd, path, mode)
-}
-
// MkdiratUser runs the Mkdirat syscall in the context of a different user.
func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error) {
if context != nil {