syscallcompat: add Renameat2 for Darwin
This commit is contained in:
parent
7c0363dee5
commit
8b1df08b8a
|
@ -21,6 +21,9 @@ const (
|
||||||
// O_PATH is only defined on Linux
|
// O_PATH is only defined on Linux
|
||||||
O_PATH = 0
|
O_PATH = 0
|
||||||
|
|
||||||
|
// RENAME_NOREPLACE is only defined on Linux
|
||||||
|
RENAME_NOREPLACE = 0
|
||||||
|
|
||||||
// KAUTH_UID_NONE and KAUTH_GID_NONE are special values to
|
// KAUTH_UID_NONE and KAUTH_GID_NONE are special values to
|
||||||
// revert permissions to the process credentials.
|
// revert permissions to the process credentials.
|
||||||
KAUTH_UID_NONE = ^uint32(0) - 100
|
KAUTH_UID_NONE = ^uint32(0) - 100
|
||||||
|
@ -131,12 +134,12 @@ func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.C
|
||||||
return Symlinkat(oldpath, newdirfd, newpath)
|
return Symlinkat(oldpath, newdirfd, newpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error) {
|
func MkdiratUser(dirfd int, path string, mode uint32, caller *fuse.Caller) (err error) {
|
||||||
if context != nil {
|
if caller != nil {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
defer runtime.UnlockOSThread()
|
defer runtime.UnlockOSThread()
|
||||||
|
|
||||||
err = pthread_setugid_np(context.Owner.Uid, context.Owner.Gid)
|
err = pthread_setugid_np(caller.Uid, caller.Gid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -215,3 +218,8 @@ func UtimesNanoAtNofollow(dirfd int, path string, a *time.Time, m *time.Time) (e
|
||||||
func Getdents(fd int) ([]fuse.DirEntry, error) {
|
func Getdents(fd int) ([]fuse.DirEntry, error) {
|
||||||
return emulateGetdents(fd)
|
return emulateGetdents(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renameat2 does not exist on Darwin, so we call Renameat and ignore the flags.
|
||||||
|
func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) {
|
||||||
|
return unix.Renameat(olddirfd, oldpath, newdirfd, newpath)
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,9 @@ const (
|
||||||
|
|
||||||
// O_PATH is only defined on Linux
|
// O_PATH is only defined on Linux
|
||||||
O_PATH = unix.O_PATH
|
O_PATH = unix.O_PATH
|
||||||
|
|
||||||
|
// RENAME_NOREPLACE is only defined on Linux
|
||||||
|
RENAME_NOREPLACE = unix.RENAME_NOREPLACE
|
||||||
)
|
)
|
||||||
|
|
||||||
var preallocWarn sync.Once
|
var preallocWarn sync.Once
|
||||||
|
@ -271,3 +274,8 @@ func UtimesNanoAtNofollow(dirfd int, path string, a *time.Time, m *time.Time) (e
|
||||||
func Getdents(fd int) ([]fuse.DirEntry, error) {
|
func Getdents(fd int) ([]fuse.DirEntry, error) {
|
||||||
return getdents(fd)
|
return getdents(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Renameat2 does not exist on Darwin, so we have to wrap it here.
|
||||||
|
func Renameat2(olddirfd int, oldpath string, newdirfd int, newpath string, flags uint) (err error) {
|
||||||
|
return unix.Renameat2(olddirfd, oldpath, newdirfd, newpath, flags)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue