mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
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 <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Ian Lance Taylor
parent
c6cbdbf9e6
commit
9a3f9b0469
@@ -12,7 +12,6 @@ package unix
|
|||||||
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
//sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error)
|
||||||
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
|
//sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_FADVISE64
|
||||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
//sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT
|
|
||||||
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
//sys Fstatfs(fd int, buf *Statfs_t) (err error)
|
||||||
//sys Ftruncate(fd int, length int64) (err error)
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
//sysnb Getegid() (egid int)
|
//sysnb Getegid() (egid int)
|
||||||
@@ -148,6 +147,7 @@ type stat_t struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//sys fstat(fd int, st *stat_t) (err error)
|
//sys fstat(fd int, st *stat_t) (err error)
|
||||||
|
//sys fstatat(dirfd int, path string, st *stat_t, flags int) (err error) = SYS_NEWFSTATAT
|
||||||
//sys lstat(path string, st *stat_t) (err error)
|
//sys lstat(path string, st *stat_t) (err error)
|
||||||
//sys stat(path string, st *stat_t) (err error)
|
//sys stat(path string, st *stat_t) (err error)
|
||||||
|
|
||||||
@@ -158,6 +158,13 @@ func Fstat(fd int, s *Stat_t) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Fstatat(dirfd int, path string, s *Stat_t, flags int) (err error) {
|
||||||
|
st := &stat_t{}
|
||||||
|
err = fstatat(dirfd, path, st, flags)
|
||||||
|
fillStat_t(s, st)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func Lstat(path string, s *Stat_t) (err error) {
|
func Lstat(path string, s *Stat_t) (err error) {
|
||||||
st := &stat_t{}
|
st := &stat_t{}
|
||||||
err = lstat(path, st)
|
err = lstat(path, st)
|
||||||
|
|||||||
@@ -1719,21 +1719,6 @@ func Fchown(fd int, uid int, gid int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
|
|
||||||
var _p0 *byte
|
|
||||||
_p0, err = BytePtrFromString(path)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, _, e1 := Syscall6(SYS_NEWFSTATAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||||
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
|
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
@@ -2293,6 +2278,21 @@ func fstat(fd int, st *stat_t) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fstatat(dirfd int, path string, st *stat_t, flags int) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_NEWFSTATAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), uintptr(flags), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func lstat(path string, st *stat_t) (err error) {
|
func lstat(path string, st *stat_t) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
|
|||||||
@@ -1719,21 +1719,6 @@ func Fchown(fd int, uid int, gid int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
|
|
||||||
var _p0 *byte
|
|
||||||
_p0, err = BytePtrFromString(path)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
_, _, e1 := Syscall6(SYS_NEWFSTATAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
func Fstatfs(fd int, buf *Statfs_t) (err error) {
|
||||||
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
|
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
@@ -2293,6 +2278,21 @@ func fstat(fd int, st *stat_t) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func fstatat(dirfd int, path string, st *stat_t, flags int) (err error) {
|
||||||
|
var _p0 *byte
|
||||||
|
_p0, err = BytePtrFromString(path)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
_, _, e1 := Syscall6(SYS_NEWFSTATAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(st)), uintptr(flags), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func lstat(path string, st *stat_t) (err error) {
|
func lstat(path string, st *stat_t) (err error) {
|
||||||
var _p0 *byte
|
var _p0 *byte
|
||||||
_p0, err = BytePtrFromString(path)
|
_p0, err = BytePtrFromString(path)
|
||||||
|
|||||||
Reference in New Issue
Block a user