From 86dbeefe1f2770daad3c8d8b46a8b7f21b2c69e1 Mon Sep 17 00:00:00 2001 From: Clément Chigot Date: Mon, 14 Sep 2020 13:06:40 +0200 Subject: 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 TryBot-Result: Go Bot Reviewed-by: Tobias Klauser Reviewed-by: Ian Lance Taylor --- src/syscall/syscall_aix.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/syscall/syscall_aix.go') diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 8bb5fa9ead..8837dd5a7f 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -214,6 +214,11 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, 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 */ @@ -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 Fstatfs(fd int, buf *Statfs_t) (err error) //sys Ftruncate(fd int, length int64) (err error) -//sys Fsync(fd int) (err error) //sysnb Getgid() (gid int) //sysnb Getpid() (pid int) //sys Geteuid() (euid int) -- cgit v1.3 From 310984bf54a52b15085e195a402873ab558d34d4 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 19 Oct 2020 12:01:23 +0200 Subject: syscall, cmd/go/internal/modload: add and use Access on aix Implement Access using Faccessat on aix following golang.org/x/sys/unix CL 262897 and switch cmd/go/internal/modload to use it to implement hasWritePerm. Change-Id: I682e44737ac2bac5a203ac1c9ddd277810454426 Reviewed-on: https://go-review.googlesource.com/c/go/+/263540 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Ian Lance Taylor Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modload/stat_openfile.go | 2 +- src/cmd/go/internal/modload/stat_unix.go | 2 +- src/syscall/syscall_aix.go | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/syscall/syscall_aix.go') diff --git a/src/cmd/go/internal/modload/stat_openfile.go b/src/cmd/go/internal/modload/stat_openfile.go index 7cdeaf47a2..5842b858f0 100644 --- a/src/cmd/go/internal/modload/stat_openfile.go +++ b/src/cmd/go/internal/modload/stat_openfile.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build aix js,wasm plan9 +// +build js,wasm plan9 // On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions // are checked by the server and group information is not known to the client, diff --git a/src/cmd/go/internal/modload/stat_unix.go b/src/cmd/go/internal/modload/stat_unix.go index 65068444d0..f49278ec3a 100644 --- a/src/cmd/go/internal/modload/stat_unix.go +++ b/src/cmd/go/internal/modload/stat_unix.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// +build darwin dragonfly freebsd linux netbsd openbsd solaris +// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris package modload diff --git a/src/syscall/syscall_aix.go b/src/syscall/syscall_aix.go index 8837dd5a7f..9c6afba442 100644 --- a/src/syscall/syscall_aix.go +++ b/src/syscall/syscall_aix.go @@ -45,6 +45,10 @@ func (ts *StTimespec_t) Nano() int64 { * Wrapped */ +func Access(path string, mode uint32) (err error) { + return Faccessat(_AT_FDCWD, path, mode, 0) +} + // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX // There is no way to create a custom fcntl and to keep //sys fcntl easily, // because we need fcntl name for its libc symbol. This is linked with the script. -- cgit v1.3