Skip to content

Commit 4ac8f55

Browse files
committed
syscall, internal/syscall/unix: fix fstatat on linux/mips64
On linux/mips64, the syscall.Stat_t struct does not match the kernel version of the struct. Functions that operate on a Stat_t translate between it and the kernel struct. The fstatat function was not doing this translation. Make it do so. Export a syscall.Fstatat on mips64 for usage by internal/syscall/unix. Perhaps we should just do this on all architectures, but this is the smaller change for now. Fixes #70659 Change-Id: I38e36473689be25861953b418c9abc5b270a7bcf Reviewed-on: https://go-review.googlesource.com/c/go/+/633280 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 236a0b4 commit 4ac8f55

File tree

5 files changed

+44
-33
lines changed

5 files changed

+44
-33
lines changed

src/internal/syscall/unix/at_fstatat.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build dragonfly || (linux && !loong64) || netbsd || (openbsd && mips64)
5+
//go:build dragonfly || (linux && !(loong64 || mips64)) || netbsd || (openbsd && mips64)
66

77
package unix
88

src/internal/syscall/unix/at_fstatat2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
//go:build freebsd || (linux && loong64)
5+
//go:build freebsd || (linux && (loong64 || mips64))
66

77
package unix
88

src/syscall/syscall_linux_mips64x.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const (
1616
//sys Dup2(oldfd int, newfd int) (err error)
1717
//sys Fchown(fd int, uid int, gid int) (err error)
1818
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
19-
//sys fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
2019
//sys Ftruncate(fd int, length int64) (err error)
2120
//sysnb Getegid() (egid int)
2221
//sysnb Geteuid() (euid int)
@@ -126,10 +125,22 @@ type stat_t struct {
126125
Blocks int64
127126
}
128127

128+
//sys fstatatInternal(dirfd int, path string, stat *stat_t, flags int) (err error) = SYS_NEWFSTATAT
129129
//sys fstat(fd int, st *stat_t) (err error)
130130
//sys lstat(path string, st *stat_t) (err error)
131131
//sys stat(path string, st *stat_t) (err error)
132132

133+
func fstatat(fd int, path string, s *Stat_t, flags int) (err error) {
134+
st := &stat_t{}
135+
err = fstatatInternal(fd, path, st, flags)
136+
fillStat_t(s, st)
137+
return
138+
}
139+
140+
func Fstatat(fd int, path string, s *Stat_t, flags int) (err error) {
141+
return fstatat(fd, path, s, flags)
142+
}
143+
133144
func Fstat(fd int, s *Stat_t) (err error) {
134145
st := &stat_t{}
135146
err = fstat(fd, st)

src/syscall/zsyscall_linux_mips64.go

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/syscall/zsyscall_linux_mips64le.go

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)