Skip to content

Commit 9a3f9b0

Browse files
anthonyfokianlancetaylor
authored andcommitted
unix: fix Fstatat by using fillStat_t on linux/mips64x
The stat structure on linux/mips64x differ between C library and the kernel, as described in the stat(2) man page. Fstat, Lstat and Stat on linux/mips64x already converts the stat structure using a fillStat_t function, very similar to __xstat_conv in GLIBC. Doing the same for Fstatat before calling SYS_NEWFSTATAT fixes the "Fstatat: returned stat does not match Stat/Lstat" error in TestFstatat. Fixes golang/go#29401 Change-Id: I0b2a7b274acc3c7c9fc7ae2afe722dd6225da383 Reviewed-on: https://go-review.googlesource.com/c/155747 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Tobias Klauser <[email protected]>
1 parent c6cbdbf commit 9a3f9b0

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

unix/syscall_linux_mips64x.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ package unix
1212
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
1313
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
1414
//sys Fchown(fd int, uid int, gid int) (err error)
15-
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
1615
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
1716
//sys Ftruncate(fd int, length int64) (err error)
1817
//sysnb Getegid() (egid int)
@@ -148,6 +147,7 @@ type stat_t struct {
148147
}
149148

150149
//sys fstat(fd int, st *stat_t) (err error)
150+
//sys fstatat(dirfd int, path string, st *stat_t, flags int) (err error) = SYS_NEWFSTATAT
151151
//sys lstat(path string, st *stat_t) (err error)
152152
//sys stat(path string, st *stat_t) (err error)
153153

@@ -158,6 +158,13 @@ func Fstat(fd int, s *Stat_t) (err error) {
158158
return
159159
}
160160

161+
func Fstatat(dirfd int, path string, s *Stat_t, flags int) (err error) {
162+
st := &stat_t{}
163+
err = fstatat(dirfd, path, st, flags)
164+
fillStat_t(s, st)
165+
return
166+
}
167+
161168
func Lstat(path string, s *Stat_t) (err error) {
162169
st := &stat_t{}
163170
err = lstat(path, st)

unix/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.

unix/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)