Skip to content

Commit

Permalink
syscall: call getfsstat via libc on openbsd
Browse files Browse the repository at this point in the history
On openbsd, call getfsstat directly via libc, instead of calling it
via syscall.Syscall.

Updates #63900

Change-Id: Ib4c581160b170e6cc6017c42e959e647d97ac993
Reviewed-on: https://go-review.googlesource.com/c/go/+/538736
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Josh Rickmar <jrick@zettaport.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
  • Loading branch information
4a6f656c committed Nov 2, 2023
1 parent 4e896d1 commit 54452b9
Show file tree
Hide file tree
Showing 13 changed files with 107 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/syscall/syscall_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,13 @@ func sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
}

func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer
var bufptr *Statfs_t
var bufsize uintptr
if len(buf) > 0 {
_p0 = unsafe.Pointer(&buf[0])
bufptr = &buf[0]
bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
}
r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
n = int(r0)
if e1 != 0 {
err = e1
}
return
return getfsstat(bufptr, bufsize, flags)
}

/*
Expand Down Expand Up @@ -212,4 +207,5 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
//sys writev(fd int, iovecs []Iovec) (n uintptr, err error)
//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
//sys munmap(addr uintptr, length uintptr) (err error)
//sys getfsstat(stat *Statfs_t, bufsize uintptr, flags int) (n int, err error)
//sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_386.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/syscall/zsyscall_openbsd_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/syscall/zsyscall_openbsd_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_arm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/syscall/zsyscall_openbsd_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/syscall/zsyscall_openbsd_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_ppc64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/syscall/zsyscall_openbsd_ppc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
CALL libc_munmap(SB)
RET
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
CALL libc_getfsstat(SB)
RET
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
CALL libc_utimensat(SB)
RET
Expand Down
15 changes: 15 additions & 0 deletions src/syscall/zsyscall_openbsd_riscv64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/syscall/zsyscall_openbsd_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
Expand Down

0 comments on commit 54452b9

Please sign in to comment.