aboutsummaryrefslogtreecommitdiff
path: root/internal/syscallcompat
diff options
context:
space:
mode:
authorJakob Unterwurzacher2017-12-02 18:32:25 +0100
committerJakob Unterwurzacher2017-12-02 18:36:18 +0100
commit77191c3485fd0a0b626aaf51382018a700057225 (patch)
tree99fe79b30fa70389914e50a5736fb05d8638756b /internal/syscallcompat
parent616a468180c5594283415e4a033f1536c955c77c (diff)
syscallcompat: use Unlinkat and Symlinkat from x/sys/unix
I'm unsure why I did not notice this earlier, but the syscall wrappers provided by x/sys/unix seem to do just fine. Drop our own version.
Diffstat (limited to 'internal/syscallcompat')
-rw-r--r--internal/syscallcompat/sys_linux.go34
1 files changed, 4 insertions, 30 deletions
diff --git a/internal/syscallcompat/sys_linux.go b/internal/syscallcompat/sys_linux.go
index e9ca7cb..0e03143 100644
--- a/internal/syscallcompat/sys_linux.go
+++ b/internal/syscallcompat/sys_linux.go
@@ -4,7 +4,6 @@ package syscallcompat
import (
"sync"
"syscall"
- "unsafe"
"golang.org/x/sys/unix"
@@ -61,19 +60,9 @@ func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err e
return syscall.Renameat(olddirfd, oldpath, newdirfd, newpath)
}
-// Unlinkat syscall. In old versions the 'flags' argument was missing, so
-// manually call it by using the corresponding syscall number.
+// Unlinkat syscall.
func Unlinkat(dirfd int, path string, flags int) (err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(path)
- if err != nil {
- return
- }
- _, _, e1 := syscall.Syscall(syscall.SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
- if e1 != 0 {
- err = e1
- }
- return
+ return unix.Unlinkat(dirfd, path, flags)
}
// Mknodat wraps the Mknodat syscall.
@@ -107,24 +96,9 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
return syscall.Fchownat(dirfd, path, uid, gid, flags)
}
-// Symlinkat syscall. Unfortunately this function is not exported directly, so
-// manually call it by using the corresponding syscall number.
+// Symlinkat syscall.
func Symlinkat(oldpath string, newdirfd int, newpath string) (err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(oldpath)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = syscall.BytePtrFromString(newpath)
- if err != nil {
- return
- }
- _, _, e1 := syscall.Syscall(syscall.SYS_SYMLINKAT, uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)))
- if e1 != 0 {
- err = e1
- }
- return
+ return unix.Symlinkat(oldpath, newdirfd, newpath)
}
// Mkdirat syscall.