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 golang/go#63900

Change-Id: I99a3555b3207754b107dbabf63440569fca93eea
Reviewed-on: https://go-review.googlesource.com/c/sys/+/538976
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Reviewed-by: Josh Rickmar <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
4a6f656c committed Nov 3, 2023
1 parent 661d749 commit cb378ae
Show file tree
Hide file tree
Showing 15 changed files with 145 additions and 8 deletions.
12 changes: 4 additions & 8 deletions unix/syscall_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,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)
}

//sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int)
Expand Down Expand Up @@ -326,6 +321,7 @@ func Uname(uname *Utsname) error {
//sys write(fd int, p []byte) (n int, 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, flags int) (err error)
//sys pledge(promises *byte, execpromises *byte) (err error)
//sys unveil(path *byte, flags *byte) (err error)
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_386.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $4
DATA ·libc_munmap_trampoline_addr(SB)/4, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $4
DATA ·libc_getfsstat_trampoline_addr(SB)/4, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $4
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_amd64.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8
DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_arm.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $4
DATA ·libc_munmap_trampoline_addr(SB)/4, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $4
DATA ·libc_getfsstat_trampoline_addr(SB)/4, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $4
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_arm64.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8
DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_mips64.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_mips64.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8
DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_ppc64.go

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

6 changes: 6 additions & 0 deletions unix/zsyscall_openbsd_ppc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,12 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_getfsstat(SB)
RET
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8
DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
CALL libc_utimensat(SB)
RET
Expand Down
15 changes: 15 additions & 0 deletions unix/zsyscall_openbsd_riscv64.go

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

5 changes: 5 additions & 0 deletions unix/zsyscall_openbsd_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ TEXT libc_munmap_trampoline<>(SB),NOSPLIT,$0-0
GLOBL ·libc_munmap_trampoline_addr(SB), RODATA, $8
DATA ·libc_munmap_trampoline_addr(SB)/8, $libc_munmap_trampoline<>(SB)

TEXT libc_getfsstat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
GLOBL ·libc_getfsstat_trampoline_addr(SB), RODATA, $8
DATA ·libc_getfsstat_trampoline_addr(SB)/8, $libc_getfsstat_trampoline<>(SB)

TEXT libc_utimensat_trampoline<>(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
GLOBL ·libc_utimensat_trampoline_addr(SB), RODATA, $8
Expand Down

0 comments on commit cb378ae

Please sign in to comment.