mirror of
https://github.com/golang/go
synced 2024-11-17 20:34:44 -07:00
syscall: fix fsync for read-only files on aix
AIX fsync syscall doesn't work on read-only files. Using fsync_range instead allows syscall.Fsync to work on any files. Fixes #41372 Change-Id: I66d33e847875496af53da60828c1bddf6c2b76b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/254657 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
4f5cd0c033
commit
86dbeefe1f
@ -214,6 +214,11 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys fsyncRange(fd int, how int, start int64, length int64) (err error) = fsync_range
|
||||||
|
func Fsync(fd int) error {
|
||||||
|
return fsyncRange(fd, O_SYNC, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Socket
|
* Socket
|
||||||
*/
|
*/
|
||||||
@ -600,7 +605,6 @@ func PtraceDetach(pid int) (err error) { return ptrace64(PT_DETACH, int64(pid),
|
|||||||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
//sys Fstat(fd int, stat *Stat_t) (err error)
|
||||||
//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)
|
||||||
//sys Fsync(fd int) (err error)
|
|
||||||
//sysnb Getgid() (gid int)
|
//sysnb Getgid() (gid int)
|
||||||
//sysnb Getpid() (pid int)
|
//sysnb Getpid() (pid int)
|
||||||
//sys Geteuid() (euid int)
|
//sys Geteuid() (euid int)
|
||||||
|
@ -19,6 +19,7 @@ import "unsafe"
|
|||||||
//go:cgo_import_dynamic libc_setgroups setgroups "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_setgroups setgroups "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_getdirent getdirent "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_getdirent getdirent "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_wait4 wait4 "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_wait4 wait4 "libc.a/shr_64.o"
|
||||||
|
//go:cgo_import_dynamic libc_fsync_range fsync_range "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_bind bind "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_bind bind "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_connect connect "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_connect connect "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Getkerninfo getkerninfo "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Getkerninfo getkerninfo "libc.a/shr_64.o"
|
||||||
@ -54,7 +55,6 @@ import "unsafe"
|
|||||||
//go:cgo_import_dynamic libc_Fstat fstat "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Fstat fstat "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Fstatfs fstatfs "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Fstatfs fstatfs "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Ftruncate ftruncate "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Ftruncate ftruncate "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Fsync fsync "libc.a/shr_64.o"
|
|
||||||
//go:cgo_import_dynamic libc_Getgid getgid "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Getgid getgid "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Getpid getpid "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Getpid getpid "libc.a/shr_64.o"
|
||||||
//go:cgo_import_dynamic libc_Geteuid geteuid "libc.a/shr_64.o"
|
//go:cgo_import_dynamic libc_Geteuid geteuid "libc.a/shr_64.o"
|
||||||
@ -111,6 +111,7 @@ import "unsafe"
|
|||||||
//go:linkname libc_setgroups libc_setgroups
|
//go:linkname libc_setgroups libc_setgroups
|
||||||
//go:linkname libc_getdirent libc_getdirent
|
//go:linkname libc_getdirent libc_getdirent
|
||||||
//go:linkname libc_wait4 libc_wait4
|
//go:linkname libc_wait4 libc_wait4
|
||||||
|
//go:linkname libc_fsync_range libc_fsync_range
|
||||||
//go:linkname libc_bind libc_bind
|
//go:linkname libc_bind libc_bind
|
||||||
//go:linkname libc_connect libc_connect
|
//go:linkname libc_connect libc_connect
|
||||||
//go:linkname libc_Getkerninfo libc_Getkerninfo
|
//go:linkname libc_Getkerninfo libc_Getkerninfo
|
||||||
@ -146,7 +147,6 @@ import "unsafe"
|
|||||||
//go:linkname libc_Fstat libc_Fstat
|
//go:linkname libc_Fstat libc_Fstat
|
||||||
//go:linkname libc_Fstatfs libc_Fstatfs
|
//go:linkname libc_Fstatfs libc_Fstatfs
|
||||||
//go:linkname libc_Ftruncate libc_Ftruncate
|
//go:linkname libc_Ftruncate libc_Ftruncate
|
||||||
//go:linkname libc_Fsync libc_Fsync
|
|
||||||
//go:linkname libc_Getgid libc_Getgid
|
//go:linkname libc_Getgid libc_Getgid
|
||||||
//go:linkname libc_Getpid libc_Getpid
|
//go:linkname libc_Getpid libc_Getpid
|
||||||
//go:linkname libc_Geteuid libc_Geteuid
|
//go:linkname libc_Geteuid libc_Geteuid
|
||||||
@ -206,6 +206,7 @@ var (
|
|||||||
libc_setgroups,
|
libc_setgroups,
|
||||||
libc_getdirent,
|
libc_getdirent,
|
||||||
libc_wait4,
|
libc_wait4,
|
||||||
|
libc_fsync_range,
|
||||||
libc_bind,
|
libc_bind,
|
||||||
libc_connect,
|
libc_connect,
|
||||||
libc_Getkerninfo,
|
libc_Getkerninfo,
|
||||||
@ -241,7 +242,6 @@ var (
|
|||||||
libc_Fstat,
|
libc_Fstat,
|
||||||
libc_Fstatfs,
|
libc_Fstatfs,
|
||||||
libc_Ftruncate,
|
libc_Ftruncate,
|
||||||
libc_Fsync,
|
|
||||||
libc_Getgid,
|
libc_Getgid,
|
||||||
libc_Getpid,
|
libc_Getpid,
|
||||||
libc_Geteuid,
|
libc_Geteuid,
|
||||||
@ -442,6 +442,16 @@ func wait4(pid _Pid_t, status *_C_int, options int, rusage *Rusage) (wpid _Pid_t
|
|||||||
|
|
||||||
// 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 fsyncRange(fd int, how int, start int64, length int64) (err error) {
|
||||||
|
_, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_fsync_range)), 4, uintptr(fd), uintptr(how), uintptr(start), uintptr(length), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
|
||||||
_, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_bind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
_, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_bind)), 3, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
@ -854,16 +864,6 @@ func Ftruncate(fd int, length int64) (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 Fsync(fd int) (err error) {
|
|
||||||
_, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Fsync)), 1, uintptr(fd), 0, 0, 0, 0, 0)
|
|
||||||
if e1 != 0 {
|
|
||||||
err = errnoErr(e1)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
|
||||||
|
|
||||||
func Getgid() (gid int) {
|
func Getgid() (gid int) {
|
||||||
r0, _, _ := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getgid)), 0, 0, 0, 0, 0, 0, 0)
|
r0, _, _ := rawSyscall6(uintptr(unsafe.Pointer(&libc_Getgid)), 0, 0, 0, 0, 0, 0, 0)
|
||||||
gid = int(r0)
|
gid = int(r0)
|
||||||
|
Loading…
Reference in New Issue
Block a user