mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-02 15:17:31 -04:00
unix: add Renameat on dragonfly
Also add a test now that all unices have Renameat. Change-Id: I9098662569e9910122dc686559bbd04be06328fa Reviewed-on: https://go-review.googlesource.com/c/157898 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
a457fd0364
commit
5552a988b7
@@ -304,6 +304,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys read(fd int, p []byte) (n int, err error)
|
//sys read(fd int, p []byte) (n int, err error)
|
||||||
//sys Readlink(path string, buf []byte) (n int, err error)
|
//sys Readlink(path string, buf []byte) (n int, err error)
|
||||||
//sys Rename(from string, to string) (err error)
|
//sys Rename(from string, to string) (err error)
|
||||||
|
//sys Renameat(fromfd int, from string, tofd int, to string) (err error)
|
||||||
//sys Revoke(path string) (err error)
|
//sys Revoke(path string) (err error)
|
||||||
//sys Rmdir(path string) (err error)
|
//sys Rmdir(path string) (err error)
|
||||||
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
|
||||||
|
|||||||
@@ -623,6 +623,29 @@ func TestMkdev(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRenameat(t *testing.T) {
|
||||||
|
defer chtmpdir(t)()
|
||||||
|
|
||||||
|
from, to := "renamefrom", "renameto"
|
||||||
|
|
||||||
|
touch(t, from)
|
||||||
|
|
||||||
|
err := unix.Renameat(unix.AT_FDCWD, from, unix.AT_FDCWD, to)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Renameat: unexpected error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(to)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = os.Stat(from)
|
||||||
|
if err == nil {
|
||||||
|
t.Errorf("Renameat: stat of renamed file %q unexpectedly suceeded", from)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// mktmpfifo creates a temporary FIFO and provides a cleanup function.
|
// mktmpfifo creates a temporary FIFO and provides a cleanup function.
|
||||||
func mktmpfifo(t *testing.T) (*os.File, func()) {
|
func mktmpfifo(t *testing.T) (*os.File, func()) {
|
||||||
err := unix.Mkfifo("fifo", 0666)
|
err := unix.Mkfifo("fifo", 0666)
|
||||||
|
|||||||
@@ -1194,6 +1194,26 @@ func Rename(from string, to string) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func Renameat(fromfd int, from string, tofd int, to string) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(from)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var _p1 *byte
|
||||||
|
_p1, err = BytePtrFromString(to)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(fromfd), uintptr(unsafe.Pointer(_p0)), uintptr(tofd), uintptr(unsafe.Pointer(_p1)), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Revoke(path string) (err error) {
|
func Revoke(path string) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user