-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft: fs: support renameExchange in loopback for darwin
Tested on MacOS 14.2 (macfuse 4.5.0) and Alpine 3.18 in Docker (Linux 6.4) Change-Id: I3f4f92c2d2aa3f4fc3696b661fa3cb0e3b43282b
- Loading branch information
Showing
10 changed files
with
121 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package renameat | ||
|
||
// Renameat is a wrapper around renameat syscall. | ||
// On Linux, it is a wrapper around renameat2(2). | ||
// On Darwin, it is a wrapper around renameatx_np(2). | ||
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) { | ||
return renameat(olddirfd, oldpath, newdirfd, newpath, flags) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package renameat | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
const ( | ||
SYS_RENAMEATX_NP = 488 | ||
RENAME_SWAP = 0x2 | ||
RENAME_EXCHANGE = RENAME_SWAP | ||
) | ||
|
||
func renameat(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) error { | ||
oldpathCString, err := syscall.BytePtrFromString(oldpath) | ||
if err != nil { | ||
return err | ||
} | ||
newpathCString, err := syscall.BytePtrFromString(newpath) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, _, errno := syscall.Syscall6( | ||
SYS_RENAMEATX_NP, | ||
uintptr(olddirfd), | ||
uintptr(unsafe.Pointer(oldpathCString)), | ||
uintptr(newdirfd), | ||
uintptr(unsafe.Pointer(newpathCString)), | ||
uintptr(flags), | ||
0, | ||
) | ||
|
||
if errno != 0 { | ||
return errno | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package renameat | ||
|
||
import "golang.org/x/sys/unix" | ||
|
||
const ( | ||
RENAME_EXCHANGE = unix.RENAME_EXCHANGE | ||
) | ||
|
||
func renameat(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) { | ||
return unix.Renameat2(olddirfd, oldpath, newdirfd, newpath, flags) | ||
} |