syscallcompat: drop obsolete wrappers
These are now available cross-platform in the unix package.
This commit is contained in:
parent
c0e7530216
commit
e48f2377ec
@ -287,13 +287,13 @@ func (n *Node) Link(ctx context.Context, target fs.InodeEmbedder, name string, o
|
||||
return
|
||||
}
|
||||
// Create "gocryptfs.longfile." link
|
||||
err = syscallcompat.Linkat(dirfd2, cName2, dirfd, cName, 0)
|
||||
err = unix.Linkat(dirfd2, cName2, dirfd, cName, 0)
|
||||
if err != nil {
|
||||
nametransform.DeleteLongNameAt(dirfd, cName)
|
||||
}
|
||||
} else {
|
||||
// Create regular link
|
||||
err = syscallcompat.Linkat(dirfd2, cName2, dirfd, cName, 0)
|
||||
err = unix.Linkat(dirfd2, cName2, dirfd, cName, 0)
|
||||
}
|
||||
if err != nil {
|
||||
errno = fs.ToErrno(err)
|
||||
|
@ -2,6 +2,8 @@ package syscallcompat
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// retryEINTR executes operation `op` and retries if it gets EINTR.
|
||||
@ -43,6 +45,24 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
|
||||
return fd, err
|
||||
}
|
||||
|
||||
// Renameat wraps the Renameat syscall.
|
||||
// Retries on EINTR.
|
||||
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
|
||||
err = retryEINTR(func() error {
|
||||
return unix.Renameat(olddirfd, oldpath, newdirfd, newpath)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Unlinkat syscall.
|
||||
// Retries on EINTR.
|
||||
func Unlinkat(dirfd int, path string, flags int) (err error) {
|
||||
err = retryEINTR(func() error {
|
||||
return unix.Unlinkat(dirfd, path, flags)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Flush is a helper for the FUSE command FLUSH.
|
||||
// Retries on EINTR.
|
||||
func Flush(fd int) error {
|
||||
|
@ -66,24 +66,6 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
||||
return fd, err
|
||||
}
|
||||
|
||||
// Renameat wraps the Renameat syscall.
|
||||
// Retries on EINTR.
|
||||
func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
|
||||
err = retryEINTR(func() error {
|
||||
return unix.Renameat(olddirfd, oldpath, newdirfd, newpath)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Unlinkat syscall.
|
||||
// Retries on EINTR.
|
||||
func Unlinkat(dirfd int, path string, flags int) (err error) {
|
||||
err = retryEINTR(func() error {
|
||||
return unix.Unlinkat(dirfd, path, flags)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Fchownat syscall.
|
||||
func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
|
||||
// Why would we ever want to call this without AT_SYMLINK_NOFOLLOW?
|
||||
@ -94,21 +76,6 @@ func Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) {
|
||||
return unix.Fchownat(dirfd, path, uid, gid, flags)
|
||||
}
|
||||
|
||||
// Linkat exists both in Linux and in MacOS 10.10+.
|
||||
func Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) {
|
||||
return unix.Linkat(olddirfd, oldpath, newdirfd, newpath, flags)
|
||||
}
|
||||
|
||||
// Symlinkat syscall.
|
||||
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)
|
||||
}
|
||||
|
||||
// Fstatat syscall.
|
||||
// Retries on EINTR.
|
||||
func Fstatat(dirfd int, path string, stat *unix.Stat_t, flags int) (err error) {
|
||||
|
@ -230,8 +230,10 @@ func symlinkCheckMode(t *testing.T, st syscall.Stat_t) {
|
||||
}
|
||||
}
|
||||
|
||||
// We used to have our own wrapper for Symlinkat. The wrapper is gone but the test
|
||||
// is still useful.
|
||||
func TestSymlinkat(t *testing.T) {
|
||||
err := Symlinkat("/foo/bar/baz", tmpDirFd, "symlink1")
|
||||
err := unix.Symlinkat("/foo/bar/baz", tmpDirFd, "symlink1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -242,7 +244,7 @@ func TestSymlinkat(t *testing.T) {
|
||||
}
|
||||
symlinkCheckMode(t, st)
|
||||
// Test with absolute path
|
||||
err = Symlinkat("/foo/bar/baz", -1, tmpDir+"/symlink2")
|
||||
err = unix.Symlinkat("/foo/bar/baz", -1, tmpDir+"/symlink2")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -253,8 +255,10 @@ func TestSymlinkat(t *testing.T) {
|
||||
symlinkCheckMode(t, st)
|
||||
}
|
||||
|
||||
// We used to have our own wrapper for Mkdirat. The wrapper is gone but the test
|
||||
// is still useful.
|
||||
func TestMkdirat(t *testing.T) {
|
||||
err := Mkdirat(tmpDirFd, "mkdirat", 0700)
|
||||
err := unix.Mkdirat(tmpDirFd, "mkdirat", 0700)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@ -266,7 +270,7 @@ func TestMkdirat(t *testing.T) {
|
||||
t.Fatalf("mkdirat did not create a directory")
|
||||
}
|
||||
// Test with absolute path
|
||||
err = Mkdirat(-1, tmpDir+"/mkdirat2", 0700)
|
||||
err = unix.Mkdirat(-1, tmpDir+"/mkdirat2", 0700)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.C
|
||||
defer pthread_setugid_np(KAUTH_UID_NONE, KAUTH_GID_NONE)
|
||||
}
|
||||
|
||||
return Symlinkat(oldpath, newdirfd, newpath)
|
||||
return unix.Symlinkat(oldpath, newdirfd, newpath)
|
||||
}
|
||||
|
||||
func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error) {
|
||||
@ -146,7 +146,7 @@ func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (er
|
||||
defer pthread_setugid_np(KAUTH_UID_NONE, KAUTH_GID_NONE)
|
||||
}
|
||||
|
||||
return Mkdirat(dirfd, path, mode)
|
||||
return unix.Mkdirat(dirfd, path, mode)
|
||||
}
|
||||
|
||||
type attrList struct {
|
||||
|
@ -204,7 +204,7 @@ func FchmodatNofollow(dirfd int, path string, mode uint32) (err error) {
|
||||
// See OpenatUser() for how this works.
|
||||
func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.Context) (err error) {
|
||||
f := func() (int, error) {
|
||||
err := Symlinkat(oldpath, newdirfd, newpath)
|
||||
err := unix.Symlinkat(oldpath, newdirfd, newpath)
|
||||
return -1, err
|
||||
}
|
||||
_, err = asUser(f, context)
|
||||
@ -217,7 +217,7 @@ func SymlinkatUser(oldpath string, newdirfd int, newpath string, context *fuse.C
|
||||
// See OpenatUser() for how this works.
|
||||
func MkdiratUser(dirfd int, path string, mode uint32, context *fuse.Context) (err error) {
|
||||
f := func() (int, error) {
|
||||
err := Mkdirat(dirfd, path, mode)
|
||||
err := unix.Mkdirat(dirfd, path, mode)
|
||||
return -1, err
|
||||
}
|
||||
_, err = asUser(f, context)
|
||||
|
Loading…
Reference in New Issue
Block a user