diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2022-09-15 23:28:49 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-19 15:51:18 +0000 |
| commit | f4becf15bdbcb098ec6cfb5373ad113b3d991d43 (patch) | |
| tree | eda362c18480b7dca52806bac560dd447ac32da8 /src/internal/syscall | |
| parent | fc1cddcfe916eff82b7c6a0e82765e9b9fe29980 (diff) | |
| download | go-f4becf15bdbcb098ec6cfb5373ad113b3d991d43.tar.xz | |
internal/syscall/unix: reuse existing {Fstat,Open,Unlink}at on freebsd
Change-Id: I517e75faca18bf0fdcd4e6c837f50f824aa6348c
Reviewed-on: https://go-review.googlesource.com/c/go/+/431236
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/internal/syscall')
| -rw-r--r-- | src/internal/syscall/unix/at.go | 2 | ||||
| -rw-r--r-- | src/internal/syscall/unix/at_freebsd.go | 47 | ||||
| -rw-r--r-- | src/internal/syscall/unix/at_fstatat2.go (renamed from src/internal/syscall/unix/at_statx.go) | 6 | ||||
| -rw-r--r-- | src/internal/syscall/unix/at_sysnum_freebsd.go | 15 |
4 files changed, 18 insertions, 52 deletions
diff --git a/src/internal/syscall/unix/at.go b/src/internal/syscall/unix/at.go index 90fcda0c75..cfb6e410b1 100644 --- a/src/internal/syscall/unix/at.go +++ b/src/internal/syscall/unix/at.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build dragonfly || linux || netbsd || (openbsd && mips64) +//go:build dragonfly || freebsd || linux || netbsd || (openbsd && mips64) package unix diff --git a/src/internal/syscall/unix/at_freebsd.go b/src/internal/syscall/unix/at_freebsd.go deleted file mode 100644 index e171f4dbb5..0000000000 --- a/src/internal/syscall/unix/at_freebsd.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2018 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package unix - -import ( - "syscall" - "unsafe" -) - -const ( - AT_REMOVEDIR = 0x800 - AT_SYMLINK_NOFOLLOW = 0x200 -) - -func Unlinkat(dirfd int, path string, flags int) error { - p, err := syscall.BytePtrFromString(path) - if err != nil { - return err - } - - _, _, errno := syscall.Syscall(syscall.SYS_UNLINKAT, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags)) - if errno != 0 { - return errno - } - - return nil -} - -func Openat(dirfd int, path string, flags int, perm uint32) (int, error) { - p, err := syscall.BytePtrFromString(path) - if err != nil { - return 0, err - } - - fd, _, errno := syscall.Syscall6(syscall.SYS_OPENAT, uintptr(dirfd), uintptr(unsafe.Pointer(p)), uintptr(flags), uintptr(perm), 0, 0) - if errno != 0 { - return 0, errno - } - - return int(fd), nil -} - -func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error { - return syscall.Fstatat(dirfd, path, stat, flags) -} diff --git a/src/internal/syscall/unix/at_statx.go b/src/internal/syscall/unix/at_fstatat2.go index 230d697b8c..8d20e1a885 100644 --- a/src/internal/syscall/unix/at_statx.go +++ b/src/internal/syscall/unix/at_fstatat2.go @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && loong64 +//go:build freebsd || (linux && loong64) package unix -import ( - "syscall" -) +import "syscall" func Fstatat(dirfd int, path string, stat *syscall.Stat_t, flags int) error { return syscall.Fstatat(dirfd, path, stat, flags) diff --git a/src/internal/syscall/unix/at_sysnum_freebsd.go b/src/internal/syscall/unix/at_sysnum_freebsd.go new file mode 100644 index 0000000000..adfbbcb92b --- /dev/null +++ b/src/internal/syscall/unix/at_sysnum_freebsd.go @@ -0,0 +1,15 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package unix + +import "syscall" + +const ( + AT_REMOVEDIR = 0x800 + AT_SYMLINK_NOFOLLOW = 0x200 + + unlinkatTrap uintptr = syscall.SYS_UNLINKAT + openatTrap uintptr = syscall.SYS_OPENAT +) |
