aboutsummaryrefslogtreecommitdiff
path: root/src/syscall/syscall_plan9.go
AgeCommit message (Collapse)Author
2024-02-26syscall: add available godoc linkcui fliter
Change-Id: I0fcb79f471cdb8b464924d9b04c675f120861f67 Reviewed-on: https://go-review.googlesource.com/c/go/+/539835 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-03-16syscall: let ENOSYS, ENOTSUP and EOPNOTSUPP implement errors.ErrUnsupportedTobias Klauser
As suggested by Bryan, also update (Errno).Is on windows to include the missing oserror cases that are covered on other platforms. Quoting Bryan: > Windows syscalls don't actually return those errors, but the dummy Errno > constants defined on Windows should still have the same meaning as on > Unix. Updates #41198 Change-Id: I15441abde4a7ebaa3c6518262c052530cd2add4b Reviewed-on: https://go-review.googlesource.com/c/go/+/476875 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-15syscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupportedTobias Klauser
As suggested by Bryan. This should fix the failing TestIPConnSpecificMethods on plan9 after CL 476217 was submitted. For #41198 Change-Id: I18e87b3aa7c9f7d48a1bd9c2819340acd1d2ca4e Reviewed-on: https://go-review.googlesource.com/c/go/+/476578 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-03-09syscall: avoid race in plan9 while syncing Chdir across goroutinesmiller
Because each M in Plan 9 runs in a separate OS process with its own current working directory, a Chdir call in one goroutine needs to be propagated to other goroutines before a subsequent syscall with a local pathname (see #9428). This is done by function syscall.Fixwd, but there is still a race if a goroutine is preempted and rescheduled on a different M between calling Fixwd and executing the syscall which it protects. By locking the goroutine to its OS thread from the start of Fixwd to the end of the protected syscall, this race can be prevented. Fixes #58802. Change-Id: I89c0e43ef4544b5bfb5db7d2158f13f24b42e1f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/474055 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-05-19syscall: make //sys lines not doc commentsRuss Cox
If they are doc comments then gofmt will put a space between // and sys. Most of syscall was already this way, following CL 7324056 (in 2013). These were not. Change-Id: Ie6ebf82809c199d0d06b87c86045bbb62b687d5f Reviewed-on: https://go-review.googlesource.com/c/go/+/407136 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
2021-12-09syscall: avoid writing to p when Pipe(p) failsRuss Cox
Generally speaking Go functions make no guarantees about what has happened to result parameters on error, and Pipe is no exception: callers should avoid looking at p if Pipe returns an error. However, we had a bug in which ForkExec was using the content of p after a failed Pipe, and others may too. As a robustness fix, make Pipe avoid writing to p on failure. Updates #50057 Change-Id: Ie8955025dbd20702fabadc9bbe1d1a5ac0f36305 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1291271 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/370577 Run-TryBot: Filippo Valsorda <filippo@golang.org> Trust: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Rakoczy <alex@golang.org>
2020-10-20all: update references to symbols moved from os to io/fsRuss Cox
The old os references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. For #41190. Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd Reviewed-on: https://go-review.googlesource.com/c/go/+/243907 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2019-09-04syscall: redirect writes to runtime.write in faketime modeAustin Clements
If the faketime build tag is set, this causes syscall.Write for FDs 1 and 2 to redirect to runtime.write, since that's where we'll apply the faketime framing. This is equivalent to what nacl currently does in naclFile.write. We do this on all of the platforms except nacl, which has its own faketime support and we're about to remove, and Windows, which would require other changes to support faketime so we're leaving alone for now. Updates #30439. Change-Id: I138a5ca63577d92d15b5437d037bd3159fa84ee7 Reviewed-on: https://go-review.googlesource.com/c/go/+/192739 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-30syscall: fix duplicate commentsmicnncim
Removed repetitions of "the" in some comments. Change-Id: I36a6f51609765076de32e1b97398c4c08743aafc GitHub-Last-Rev: 4d06aea6a787cfca40eda10845897ff149fff62c GitHub-Pull-Request: golang/go#33797 Reviewed-on: https://go-review.googlesource.com/c/go/+/191497 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-08-22syscall: document relationship among Errno, errors.Is and os.Err*Jonathan Amsterdam
- Add doc to syscall.Errno (and syscall.ErrorString for plan9). - Mention under `syscall` in release notes. Fixes #33436. Change-Id: I032ffebaa76ed67eb9d748e7645ca73f26144ea0 Reviewed-on: https://go-review.googlesource.com/c/go/+/191337 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-02all: remove os.ErrTimeoutDamien Neil
It is unclear whether the current definition of os.IsTimeout is desirable or not. Drop ErrTimeout for now so we can consider adding it (or some other error) in a future release with a corrected definition. Fixes #33411 Change-Id: I8b880da7d22afc343a08339eb5f0efd1075ecafe Reviewed-on: https://go-review.googlesource.com/c/go/+/188758 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-01all: remove os.ErrTemporaryDamien Neil
As discussed in https://github.com/golang/go/issues/32463#issuecomment-506833421 the classification of deadline-based timeouts as "temporary" errors is a historical accident. I/O timeouts used to be duration-based, so they really were temporary--retrying a timed-out operation could succeed. Now that they're deadline-based, timeouts aren't temporary unless you reset the deadline. Drop ErrTemporary from Go 1.13, since its definition is wrong. We'll consider putting it back in Go 1.14 with a clear definition and deprecate net.OpError.Temporary. Fixes #32463 Change-Id: I70cda664590d8872541e17409a5780da76920891 Reviewed-on: https://go-review.googlesource.com/c/go/+/188398 Reviewed-by: Jonathan Amsterdam <jba@google.com>
2019-03-20os: make errors.Is work with ErrPermission et al.Damien Neil
As proposed in Issue #29934, update errors produced by the os package to work with errors.Is sentinel tests. For example, errors.Is(err, os.ErrPermission) is equivalent to os.IsPermission(err) with added unwrapping support. Move the definition for os.ErrPermission and others into the syscall package. Add an Is method to syscall.Errno and others. Add an Unwrap method to os.PathError and others. Updates #30322 Updates #29934 Change-Id: I95727d26c18a5354c720de316dff0bffc04dd926 Reviewed-on: https://go-review.googlesource.com/c/go/+/163058 Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
2018-02-28syscall: reduce redundant getwd tracking in Plan 9Richard Miller
In Plan 9, each M is implemented as a separate OS process with its own working directory. To keep the wd consistent across goroutines (or rescheduling of the same goroutine), CL 6350 introduced a Fixwd procedure which checks using getwd and calls chdir if necessary before any syscall operating on a pathname. This wd checking will not be necessary if the pathname is absolute (starts with '/' or '#'). Getwd is a fairly expensive operation in Plan 9 (implemented by opening "." and calling Fd2path on the file descriptor). Eliminating the redundant getwd calls can significantly reduce overhead for common operations like "dist test --list" which perform many syscalls on absolute pathnames. Updates #9428. Change-Id: I13fd9380779de27b0ac2f2b488229778d6839255 Reviewed-on: https://go-review.googlesource.com/97675 Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: David du Colombier <0intro@gmail.com>
2018-02-20syscall: ensure Mkdir(path) on Plan 9 fails if path existsRichard Miller
On Plan 9, the underlying create() syscall with DMDIR flag, which is used to implement Mkdir, will fail silently if the path exists and is not a directory. Work around this by checking for existence first and rejecting Mkdir with error EEXIST if the path is found. Fixes #23918 Change-Id: I439115662307923c9f498d3e7b1f32c6d205e1ad Reviewed-on: https://go-review.googlesource.com/94777 Reviewed-by: David du Colombier <0intro@gmail.com>
2017-09-27syscall: make Exit call runtime.exitAlex Brainman
syscall.Exit and runtime.exit do the same thing. Why duplicate code? CL 45115 fixed bug where windows runtime.exit was correct, but syscall.Exit was broken. So CL 45115 fixed windows syscall.Exit by calling runtime.exit. Austin suggested that all OSes should do the same, and this CL implements his idea. While making changes, I discovered that nacl syscall.Exit returned error func Exit(code int) (err error) and I changed it into func Exit(code int) like all other OSes. I assumed it was a mistake and it is OK to do because cmd/api does not complain about it. Also I changed plan9 runtime.exit to accept int32 just like all other OSes do. Change-Id: I12f6022ad81406566cf9befcc6edc382eebd413b Reviewed-on: https://go-review.googlesource.com/66170 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David du Colombier <0intro@gmail.com>
2017-08-15runtime: remove unused global variable emptystringIan Lance Taylor
Last runtime use was removed in https://golang.org/cl/133700043, September 2014. Replace plan9 syscall uses with plan9-specific variable. Change-Id: Ifb910c021c1419a7c782959f90b054ed600d9e19 Reviewed-on: https://go-review.googlesource.com/55450 Reviewed-by: Martin Möhrmann <moehrmann@google.com> Run-TryBot: Martin Möhrmann <moehrmann@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-13syscall: delete the "use" function and calls in non-generated files.Sameer Ajmani
Delete use stub from asm.s, leaving only a dummy file. Deleting the file causes Windows build to fail. Fixes #16607 Change-Id: Ic5a55e042e588f1e1bc6605a3d309d1eabdeb288 Reviewed-on: https://go-review.googlesource.com/36716 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-09-06syscall: make Getpagesize return page size from runtimeAustin Clements
syscall.Getpagesize currently returns hard-coded page sizes on all architectures (some of which are probably always wrong, and some of which are definitely not always right). The runtime now has this information, queried from the OS during runtime init, so make syscall.Getpagesize return the page size that the runtime knows. Updates #10180. Change-Id: I4daa6fbc61a2193eb8fa9e7878960971205ac346 Reviewed-on: https://go-review.googlesource.com/25051 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-05syscall: simplify closing of extra fds in plan9 StartProcessRichard Miller
Reviving earlier work by @ality in https://golang.org/cl/57890043 to make the closing of extra file descriptors in syscall.StartProcess less race-prone. Instead of making a list of open fds in the parent before forking, the child can read through the list of open fds and close the ones not explicitly requested. Also eliminate the complication of keeping open any extra fds which were inherited by the parent when it started. This CL will be followed by one to eliminate the ForkLock in plan9, which is now redundant. Fixes #5605 Change-Id: I6b4b942001baa54248b656c52dced3b62021c486 Reviewed-on: https://go-review.googlesource.com/22610 Run-TryBot: David du Colombier <0intro@gmail.com> Reviewed-by: David du Colombier <0intro@gmail.com>
2015-04-09syscall: reduce the set of architecture-dependent files on Plan 9Anthony Martin
Change-Id: I98b172181c2fd85aa385341e28bc661dbc274252 Reviewed-on: https://go-review.googlesource.com/2167 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-01syscall: fix mount working directory on Plan 9David du Colombier
In CL 6350, Brad fixed the following system calls to use the program-wide workding directory: - bind - chdir - create - open - remove - stat - umount - wstat However, Russ Cox pointed out that the mount system call should be fixed as well. Change-Id: I6139ed11ba449f18c46e95269f4d0e51be7cec48 Reviewed-on: https://go-review.googlesource.com/6385 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-28syscall: make pwd process-wide on Plan 9Brad Fitzpatrick
On Plan 9, the pwd is apparently per-thread not per process. That means different goroutines saw different current directories, even changing within a goroutine as they were scheduled. Instead, track the the process-wide pwd protected by a mutex in the syscall package and set the current goroutine thread's pwd to the correct once at critical points. Fixes #9428 Change-Id: I928e90886355be4a95c2be834f5883e2b50fc0cf Reviewed-on: https://go-review.googlesource.com/6350 Reviewed-by: David du Colombier <0intro@gmail.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2014-09-08syscall: keep allocated C string live across call to SyscallRuss Cox
Given: p := alloc() fn_taking_ptr(p) p is NOT recorded as live at the call to fn_taking_ptr: it's not needed by the code following the call. p was passed to fn_taking_ptr, and fn_taking_ptr must keep it alive as long as it needs it. In practice, fn_taking_ptr will keep its own arguments live for as long as the function is executing. But if instead you have: p := alloc() i := uintptr(unsafe.Pointer(p)) fn_taking_int(i) p is STILL NOT recorded as live at the call to fn_taking_int: it's not needed by the code following the call. fn_taking_int is responsible for keeping its own arguments live, but fn_taking_int is written to take an integer, so even though fn_taking_int does keep its argument live, that argument does not keep the allocated memory live, because the garbage collector does not dereference integers. The shorter form: p := alloc() fn_taking_int(uintptr(unsafe.Pointer(p))) and the even shorter form: fn_taking_int(uintptr(unsafe.Pointer(alloc()))) are both the same as the 3-line form above. syscall.Syscall is like fn_taking_int: it is written to take a list of integers, and yet those integers are sometimes pointers. If there is no other copy of those pointers being kept live, the memory they point at may be garbage collected during the call to syscall.Syscall. This is happening on Solaris: for whatever reason, the timing is such that the garbage collector manages to free the string argument to the open(2) system call before the system call has been invoked. Change the system call wrappers to insert explicit references that will keep the allocations alive in the original frame (and therefore preserve the memory) until after syscall.Syscall has returned. Should fix Solaris flakiness. This is not a problem for cgo, because cgo wrappers have correctly typed arguments. LGTM=iant, khr, aram, rlh R=iant, khr, bradfitz, aram, rlh CC=dvyukov, golang-codereviews, r https://golang.org/cl/139360044
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.