52 Commits

Author SHA1 Message Date
Tobias Klauser
a7f19e9c20 unix: add Dup3 on dragonfly
Use the same implementation as on freebsd which is also what the
dragonfly libc uses.

Change-Id: I0ed513ae15fcb6dac77b2fc76f662723d66b75c6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/636435
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-12-17 08:13:49 -08:00
Tobias Klauser
2964e1e4b1 unix: remove unused readlen and writelen
These were originally added when copying over files from package
syscall. However, their use was removed in CL 129500043. New ports kept
adding these wrappers without using them. They are still unused, so
remove them.

Change-Id: I2ffffe98a5c999d23b63d1f04ee4ad8f807ee736
Reviewed-on: https://go-review.googlesource.com/c/sys/+/531356
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-28 17:55:56 +00:00
Tobias Klauser
807530fc6d unix: remove lists of unimplemented syscalls
These lists are incomplete and out of date, so there's not much point
in keeping them around.

Change-Id: I0a45905c774b751f0a744f1df88bccb0554a6ab1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/530896
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-27 13:17:34 +00:00
Ian Lance Taylor
ff18efa0a3 unix: change Setrlimit/Prlimit to always call syscall functions
As of Go 1.21 syscall.Setrlimit and syscall.prlimit can affect
starting a new process, by restoring the original NOFILE rlimit.
That is recorded locally in the syscall package, so just always
call the syscall functions.

For golang/go#46279

Change-Id: I2f3dafe5562a7dde1297bad6f5d34a80af5d620b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/476695
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-03-15 21:12:13 +00:00
Dmitri Goutnik
10499f4574 unix: add ioctlPtr with unsafe.Pointer arg on other unices (cont)
CL 469315 missed a few conversions, this CL adds them. While
here, also update syscall wrapper generators.

For golang/go#44834

Change-Id: I4418a8c177ee6d1a269c1cc2c806b199dc7ccf0b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/471119
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-24 21:46:34 +00:00
Tobias Klauser
cffae8ece4 unix: add ClockGettime on *bsd and solaris
The same wrapper is already implemented on linux and darwin.

Change-Id: Ia986fdfc28767356451d157e53f11e8d9ca86f2c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/456795
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-12-13 14:01:47 +00:00
Russ Cox
b5fbb4746d all: gofmt
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: I9a1c4b671c06820a1c383ee515f7884965fefa54
Reviewed-on: https://go-review.googlesource.com/c/sys/+/399602
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-04-29 23:34:32 +00:00
Tobias Klauser
530d0810a4 unix: add utimensat libc wrapper on darwin
Direct syscalls are no longer supported on darwin (CL 250437), so
utimensat can be implemented as a wrapper around the libc function.
The utimensat function was added in macOS 10.13 and Go 1.17 dropped
support for macOS 10.12.

This also allows to drop the fallback to setattrlistTimes which was
used to set timestamps with nanosecond resolution before utimensat could
be used, see golang/go#22528 and CL 74952.

Change-Id: I206291277e6f7200ca7a659e29075968647779a6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/251737
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-03-27 21:02:14 +00:00
Tobias Klauser
039c03cc5b unix: add race annotations to Pread and Pwrite
Follow CL 391954 which changed Pread/Pwrite in package syscall.

For golang/go#51618

Change-Id: Icc587c61f083886bb66ca96717f686f56b398e34
Reviewed-on: https://go-review.googlesource.com/c/sys/+/392794
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-03-15 19:43:20 +00:00
Russ Cox
798191bca9 unix, plan9: avoid writing to p when Pipe(p) fails
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.

windows.Pipe already avoided writing to p on failure.

For golang/go#50057.

Change-Id: I93ed06b06a9981793c119c1d7df689fbe79b4116
Reviewed-on: https://go-review.googlesource.com/c/sys/+/370614
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-09 17:19:07 +00:00
Tobias Klauser
2738c018e2 unix: fix Pipe2 on dragonfly
The pipe2 on dragonfly still expects an fds array as an argument, but
does not use it to return the file descriptors. Just pass the argument
but ignore its value. This way the flags argument will be respected
correctly.

Change-Id: Id340653040999f31074eae01e9be4ea2088abae5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/295870
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-25 09:19:36 +00:00
Tobias Klauser
e8e29180ff unix: fix Pipe2 on dragonfly
Also move TestPipe2 into a separate file, enabling it for all platforms
where Pipe2 is available.

Change-Id: I9c554a53fc9d7610aaa732c0ceba864963fad542
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283598
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2021-02-18 08:40:38 +00:00
Tobias Klauser
73548a7a48 unix: consistently use tabs in //sys and //sysnb lines
There is some inconsistent use of tabs and spaces in the //sys and
//sysnb lines. However, the large majority is using tabs, so use these
consistently.

Also change the regexp in mksyscall*.go to only accept tabs going
forward.

Change-Id: I78944e88b5fec11c1bd1d103cea894bc5109da56
Reviewed-on: https://go-review.googlesource.com/c/sys/+/283596
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-02-17 08:59:31 +00:00
Tobias Klauser
f84b799fce unix: add Pipe2 on dragonfly
The pipe2 syscall is available since DragonflyBSD 4.2, see
https://www.dragonflybsd.org/release42/

Change-Id: I94631fd64ee731e416049cac5f3d15544f1337dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/271177
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2020-11-19 10:28:17 +00:00
Tobias Klauser
9d1ec526b7 unix: add anyToSockaddrGOOS on dragonfly
CL 264638 forgot to add func anyToSockaddrGOOS on dragonfly which breaks
the build.

Change-Id: I35d28a972c8c541dea8db0349b7e1440f5ec2fd7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/265377
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2020-10-27 13:05:17 +00:00
Tobias Klauser
9d91bd6205 unix: implement Getwd using getcwd from libSystem on darwin
Directly wrap the getcwd implementation provided by libSystem.dylib on
darwin and use it to implement Getwd like on the BSDs. This allows to
drop the custom implementation using getAttrList and to merge the
implementation of Getwd for darwin and the BSDs in syscall_bsd.go.

Change-Id: I62d38a239a7279fb95c912344bda2830856d4da4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/257497
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-09-26 10:08:07 +00:00
Jason A. Donenfeld
f89234f9a2 unix: __sysctl is sysctl on darwin
While the other BSDs use __sysctl as the name, Darwin now uses sysctl,
without the leading underscores, and considers __sysctl to be "private".
Using __sysctl leads to App Store rejections, and Go's syscall package
already uses the proper syscall. So this commit changes Darwin's syscall
to use it too here, while reverting a recent commit that removed it all
together on arm and arm64.

This reverts CL 194097.

Fixes golang/go#35103
Updates golang/go#34133
Updates golang/go#35101

Change-Id: Ic72d5e7a435b99fe62c533b77b2c3790590f4c9e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/202837
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-10-23 15:13:26 +00:00
Tobias Klauser
3e7259c5e7 unix: don't use 32-bit aligned access for cmsgAlignOf on dragonfly after ABI change
Use 32-bit alignment for versions before the September 2019 ABI changes
http://lists.dragonflybsd.org/pipermail/users/2019-September/358280.html

Follows CL 201977 which did the same for package syscall.

Updates golang/go#34958

Change-Id: I0e13fccf6563e4d34dd4aa7410be044881f220aa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/202179
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-20 21:24:54 +00:00
Tobias Klauser
2aa67d56cd unix: fix Select to return number of ready fds on Darwin and *BSD
Make Select's signature on Darwin and the BSDs match the one on Linux
and return the number of ready file descriptors.

Fixes golang/go#34458

Change-Id: Ia618ce34ff754f2b731d7f913cab840d7948579c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/196802
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-24 06:27:00 +00:00
Elias Naur
d223b2b6db unix: disable sysctl on iOS
Running the regenerating scripts also brought in ClockGettime.

Updates golang/go#34133

Change-Id: I0eb9ed6dbbc2bdd7e3d2a7f5d88492e9dfed0ada
Reviewed-on: https://go-review.googlesource.com/c/sys/+/194097
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-07 18:44:12 +00:00
Kir Kolyshkin
08d80c9d36 unix: unify Ioctl* functions
Unify Ioctl* functions common across the different UNIX OSs.

Change-Id: I2376d97a7162e7e6518f75faf9317ffc87962411
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192358
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-08-30 08:01:33 +00:00
Tobias Klauser
e07cf5db27 unix: don't use syscall.ParseDirent
Implement ParseDirent in x/sys/unix instead of calling
syscall.ParseDirent. The latter uses offsets into syscall.Dirent which
might not be matching unix.Dirent depending on Go version. This is e.g.
the case with of FreeBSD whose Dirent structure was updated for Go 1.12.

This fixes TestDirent and TestGetdirentries on freebsd with Go 1.11

Reverts CL 88475

Change-Id: I04318f59c6fbf148c75ce3667255a0c0428288e2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183897
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-06-26 15:08:13 +00:00
Tobias Klauser
c5567b49c5 unix: add Getdents on dragonfly
Add a syscall wrapper for Getdents on dragonfly and use it to
implement ReadDirent

Change-Id: Ie54c0edeaf89491cab2355557fb442bd5bec2987
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183227
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-06-24 14:20:23 +00:00
Tobias Klauser
5552a988b7 unix: add Renameat on dragonfly
Also add a test now that all unices have Renameat.

Change-Id: I9098662569e9910122dc686559bbd04be06328fa
Reviewed-on: https://go-review.googlesource.com/c/157898
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-16 15:07:22 +00:00
Keith Randall
7c4c994c65 unix: remove raw syscall from Sendfile
Update golang/go#17490

Change-Id: Iaec54b8ffda1a24d4c8b5671185d570fb8683155
Reviewed-on: https://go-review.googlesource.com/c/154663
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-12-20 18:20:59 +00:00
Tobias Klauser
7e31e0c00f unix: add remaining *at functions on dragonfly
Add Faccessat, Fchownat, Linkat, Mkdirat, Mknodat, Symlinkat and
Unlinkat.

Change-Id: I9a2758ea2ca31aa59c57ead01838c08cbab2bbe1
Reviewed-on: https://go-review.googlesource.com/c/145819
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-30 15:01:19 +00:00
Tobias Klauser
95b1ffbd15 unix: add Openat on dragonfly
Change-Id: I1bf134301e5e81e6d6524bf63532975166694db6
Reviewed-on: https://go-review.googlesource.com/c/144978
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-26 20:36:30 +00:00
Brad Fitzpatrick
e072cadbbd unix: document IoctlSetWinsize and IoctlSetTermios and fix pointer lifetime
Change-Id: I42e59149e58bd928d9beb2c6665ce186b377d2a1
Reviewed-on: https://go-review.googlesource.com/125640
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-24 21:28:12 +00:00
Alexander Menzhinsky
1b2967e3c2 unix: implement RFCOMM sockets on Linux
Add the SockaddrRFCOMM type and the ability to accept BTPROTO_L2CAP and BTPROTO_RFCOMM protocol sockets.

Fixes golang/go#22211

Change-Id: I580b526c5392b90663499af0f2ebe6f55b1f8154
Reviewed-on: https://go-review.googlesource.com/122457
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-07-09 06:02:33 +00:00
Tobias Klauser
7ceb54c841 unix: add Fchmodat on DragonflyBSD
Change-Id: I3fd96550d588373d75e14bd554d46e2590c266fb
Reviewed-on: https://go-review.googlesource.com/101596
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-20 10:47:26 +00:00
Tobias Klauser
0edb963348 unix: add Fstatat on DragonflyBSD
Change-Id: Ie4a172a36a274334a49766cc272e74bcc34ebd86
Reviewed-on: https://go-review.googlesource.com/100576
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-14 12:53:46 +00:00
Tobias Klauser
0346725895 unix: add godoc for Sockaddr* types
Add rudimentary godoc for all existing Sockaddr* types implementing the
Sockaddr interface.

Change-Id: Ida7d1e8756477b54fc773f4bc978002c3d4a376d
Reviewed-on: https://go-review.googlesource.com/89775
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-01-25 14:53:36 +00:00
Tobias Klauser
af50095a40 unix: use ParseDirent from syscall
Just call syscall's implementation instead of duplicating ParseDirent
and the GOOS-specific private functions needed by it.

Change-Id: Icf49769390929463323608e093dd2a3d1c0ae4d3
Reviewed-on: https://go-review.googlesource.com/88475
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-01-22 08:19:59 +00:00
Tobias Klauser
1d2aa6dbde unix: add Getcwd to support Getwd on all BSDs
All BSDs provide the SYS___GETCWD syscall which can be used to implement
Getwd.

Also add a test based on TestChdirAndGetwd from os/os_test.go

Change-Id: I243eae3e02a40e92afad317eb1f8a28b6032c131
Reviewed-on: https://go-review.googlesource.com/83755
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-12-14 07:29:55 +00:00
Tobias Klauser
9167dbfd0f unix: add Uname on dragonfly
The Utsname members are only 32 bytes on Dragonfly and the syscall
returns ENOMEM in case the value is longer than that. Like uname(3)
on Dragonfly, handle this case gracefully and just truncate the
value.

Change-Id: If617af1b6831cff6d4245f498dad9f264b8fd118
Reviewed-on: https://go-review.googlesource.com/82155
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-12-06 14:41:49 +00:00
Tobias Klauser
5404d63da1 unix: add ioctl functions on Dragonfly
Add IoctlGetInt/IoctlSetInt, IoctlGetTermios/IoctlSetTermios and
IoctlGetWinsize/IoctlSetWinsize on Dragonfly. These are similar to the
already existing implementations on Linux, Darwin and Solaris.

Change-Id: I5a5a7ef69f02e01a4216779df5c927f241e5cec0
Reviewed-on: https://go-review.googlesource.com/76170
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-06 15:25:04 +00:00
Tobias Klauser
46eaec7899 unix: use setattrlist for UtimesNanoAt on Darwin
Use to setarrlist to implement UtimesNanoAt with nanosecond precision
(on Mac OS 10.13 with APFS). Translate AT_SYMLINK_NOFOLLOW to
FSOPT_NOFOLLOW correspondingly.

Change-Id: I1468a1f4eecb53b2280ff6329b1ec64e204701f1
Reviewed-on: https://go-review.googlesource.com/75650
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-02 21:26:49 +00:00
Tobias Klauser
feaf45c67f unix: use setattrlist for UtimesNano on Darwin for ns resolution
Follow CL 74952 for x/sys/unix.

Update golang/go#22528

Change-Id: Id146da75b80a64cfa4eac28e9bb7b3befe944718
Reviewed-on: https://go-review.googlesource.com/75610
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-02 20:14:56 +00:00
Tobias Klauser
af4555b109 unix: move Poll implementation for BSDs into syscall_bsd.go
Now that all BSD flavors support Poll, move the common implementation
into syscall_bsd.go

Change-Id: Id62a6163d41ef24e33f96540b661002b095a2fa1
Reviewed-on: https://go-review.googlesource.com/74290
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-31 08:18:28 +00:00
Tobias Klauser
607525c0eb unix: add Poll function on Dragonfly
Tested with TestPoll extracted from syscall_linux_test.go. Once Poll is
supported on all OSes this test can be moved to syscall_unix_test.go.

Change-Id: I03f4396be2e190770abb219c1c5324ca55bcfa27
Reviewed-on: https://go-review.googlesource.com/73430
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-25 19:14:39 +00:00
Tobias Klauser
43e60d72a8 unix: unify memory functions on BSD
Make Madvice, Mlock, Mlockall, Mprotect, Msync, Munlock and Munlockall
available equally on all BSD flavors. NetBSD was previously lacking
SYS_MSYNC, so add it.

Reorder the //sys function prototype alphabetically and clean up already
implemented syscalls everywhere.

Also add tests for Mprotect, Msync and Madvice - now that they're
available on all unix platforms.

Fixes golang/go#18513

Change-Id: I0eb502d72c7e991f191fb96225ef04e8297d8b8d
Reviewed-on: https://go-review.googlesource.com/56172
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 23:46:08 +00:00
Tobias Klauser
2d3e384235 unix: add utimensat and use it for UtimesNano on BSD
Follow golang.org/cl/55130 and add the utimensat syscall on *BSD. Use it
in UtimesNano and UtimesNanoAt (which is added on *BSD, akin to the
already existing implementation on Linux and Solaris).

Also add AT_FDCWD and AT_SYMLINK_NOFOLLOW where they are missing. These
might be used with UtimesNanoAt.

In order to be able to generate the syscalls, also add two missing
$GOOS_$GOARCH patterns to mkall.sh. As a side effect, some additional
syscalls are added for openbsd/arm.

Change-Id: I85351098002209f8454ec328cef0cfe9d12c5214
Reviewed-on: https://go-review.googlesource.com/55071
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-14 19:17:52 +00:00
Mikio Hara
9ccfe848b9 unix: sync with DragonFly BSD 4.8 kernel
Also adds support for accept4 system call.

Change-Id: Ib4f15a3ac47ad2fa86ac2f22331a061ddda12d82
Reviewed-on: https://go-review.googlesource.com/41833
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-27 04:18:56 +00:00
Ian Lance Taylor
9f30dcbe5b unix: fix build on DragonFly BSD
The code was broken such that it didn't compile. With this fix, it compiles.

Fixes golang/go#20055.

Change-Id: I9aeb4900f2c99b2ad254be75b4987913cae71e14
Reviewed-on: https://go-review.googlesource.com/41672
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-25 13:52:08 +00:00
Koki Ide
9a7256cb28 unix: validate ParseDirent inputs
This is a copy of https://golang.org/cl/23780 for the x/sys repo.

Don't panic, crash, or return references to uninitialized memory when 
ParseDirent is passed invalid input.

Updates golang/go#15653
Fixes golang/go#19754

Change-Id: Idb7cffe14d48ed662e5a55ecb5249c1907cf4003
Reviewed-on: https://go-review.googlesource.com/38758
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-29 06:16:34 +00:00
Sameer Ajmani
aaabbdc969 x/sys/unix: remove the "use" function and its calls.
Update mksyscall*.pl to skip generating calls to "use".
Make build tag handling match what's used in the syscall package.

See issue https://golang.org/issue/16607
and CL https://golang.org/cl/36616

Change-Id: I2d2e823fe1846d2110c07eb1bf976852706ecf60
Reviewed-on: https://go-review.googlesource.com/36715
Run-TryBot: Sameer Ajmani <sameer@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-10 16:30:38 +00:00
Mikio Hara
a408501be4 unix: fix missing use of use function in Getfsstat and Getwd
Updates golang/go#13372.

Change-Id: I623de97eb19880356148cbcb7d17759df82684aa
Reviewed-on: https://go-review.googlesource.com/24751
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-07-04 03:17:55 +00:00
Ian Lance Taylor
5829c74886 unix: change Dup,Dup2,Dup3 to use Syscall, not RawSyscall
This avoids hanging when a Go program uses a FUSE filesystem and the
dup system call has to close a file descriptor.  When dup uses
RawSyscall then the goroutine calling dup will occupy a scheduler slot
(a p structure) during the call, and may block waiting for some other
goroutine to respond to the close call on the FUSE filesystem.
Changing to Syscall avoids the problem.  This makes Dup a tiny bit
slower but is quite unlikely to make a difference for any real
programs.

Update golang/go#10202.

Change-Id: I590c5c9a04e0a1281a85dc553c7592fa83949ac7
Reviewed-on: https://go-review.googlesource.com/8056
Reviewed-by: Rob Pike <r@golang.org>
2015-03-26 17:59:35 +00:00
William Orr
853bdd547a unix: add mlock/munlock/mlockall/munlockall/mprotect to *BSD
Change-Id: I01c5dd902bbc349b860600ec2b3d556e2dc406c9
Reviewed-on: https://go-review.googlesource.com/1921
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-06 02:05:08 +00:00
Rob Pike
dc3c21c62b go.sys/unix: use syscall.Errno for errors
If we use a local type, it won't compare properly with errors from
the rest of the standard library. Errors are the one type from syscall
that propagates through the system, so it's important to have only
one type for them.

Ditto for syscall.Signal.

LGTM=dave
R=rsc, dave
CC=golang-codereviews
https://golang.org/cl/123490043
2014-08-15 09:57:24 -07:00