Commit Graph

792 Commits

Author SHA1 Message Date
Tobias Klauser
bbd175535a unix: add Msghdr.SetIovlen for solaris/amd64
Follow-up for CL 194077

Updates golang/go#34164

Change-Id: I4bf670dc3e13c483e9087dc3f04973278a09b2f4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/194099
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-10 06:45:55 +00:00
andig
f460065e89 unix: add Msghdr.SetIovlen
Fixes golang/go#34164

Change-Id: I77e634fafe8e573d5d2c65ddae9b0771c9f3e88f
GitHub-Last-Rev: dd25f06f86
GitHub-Pull-Request: golang/sys#42
Reviewed-on: https://go-review.googlesource.com/c/sys/+/194077
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-09 08:27:30 +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
Tobias Klauser
749cb33bea cpu: add a space before build tag comment
Add a space before build tag comments so it corresponds to the format
documented at https://golang.org/pkg/go/build/.

Change-Id: Ia7c724daf70d419dec52a652188799441053a867
Reviewed-on: https://go-review.googlesource.com/c/sys/+/193198
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-04 15:47:56 +00:00
Matt Layher
43c01164e9 unix: implement AF_TIPC sockets on Linux
Adds initial constants and types to use with SockaddrTIPC. For more
information on TIPC, see: http://tipc.sourceforge.net/.

Because the C struct sockaddr_tipc makes use of a union for its addr
field, I have created a wrapping layer in SockaddrTIPC that uses
an interface to determine which variant is in use.

Tests accompany this change due to the complexity of this code. There
is currently little test coverage in the Sockaddr-related code, but
perhaps this is something that could be picked up as a relatively
straightforward task for a new contributor.

Change-Id: I5033a0685cb7128d4b1a23d18aca71c202d0c0aa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/187960
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-09-04 00:50:37 +00:00
Matt Layher
1f305c863d unix/linux: upgrade Docker build container to Go 1.13
Change-Id: I1f47efb573ff3fa77afd9d1433726a908008c27d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/193119
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-03 21:38:30 +00:00
Kir Kolyshkin
9109b7679e unix: add IoctlRetInt for Linux
Add IoctlRetInt() for ioctls that use syscall's return value
as an output parameter. Add a unit test for Linux, and the
NS_GET_ defines that it requires (see ioctl_ns(2)).

Motivation:

Currently, x/sys/unix provides a few functions to deal with ioctls.
In particular, IoctlGetInt(), which "performs an ioctl operation
which gets an integer value". It does that by passing a pointer
to an integer to a syscall and returning that integer. The value
returned from syscall is treated as success/failure flag
(0 means success, -1 means failure, and in such case errno
is used to figure out the underlying error).

It appears that there are a few ioctls in Linux and at least one
in Solaris, which do not use the above way to return an int, instead
they use the syscall's return value (in case it's not negative).

As Linux ioctl(2) man page says,

> RETURN VALUE
> Usually, on success zero is returned. A few ioctl() requests
> use the return value as an output parameter and return
> a nonnegative value on success. On error, -1 is returned,
> and errno is set appropriately.

Currently I am aware of at least 6 Linux ioctls that do that
(return the value directly):

* LOOP_CTL_* ioctls on /dev/loop-control (all 3 of them). Source: loop(4)
* NS_* ioctls (3 out of 4) on /proc/PID/ns/*. Source: ioctl_ns(2)

And one in Solaris:

* I_FIND ioctl, source: streamio(7i).

There might be some more ioctls like the ones above, but since
ioctls are scarcely documented, it is hard to say how many more.

Obviously, using IoctlGetInt() for such ioctls would be a big
mistake, as 0 will always be returned. For example, there was
a bug in Docker's pkg/loopback (moby/moby#39801).

[v6: make it linux-specific for now]

Fixes golang/go#33966

Change-Id: Ie64f72fd84101b955ba14519a357e06a66d685d0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192780
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-09-02 13:37:55 +00:00
Clément Chigot
1e83adbbeb unix: fix coredump bit on aix/ppc64
Change-Id: Id7a299f240bf1d6394c7d2acb6fd93b9f8f6ca27
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192359
Run-TryBot: Clément Chigot <clement.chigot@atos.net>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-08-30 14:29:57 +00:00
Jason A. Donenfeld
acfa387b8d windows: open process tokens with duplicate access
A usual thing to ask is, "Is my current token in group X?" The right way
of doing such a thing is:

	processToken, err := windows.OpenCurrentProcessToken()
	if err != nil {
		return false, err
	}
	defer processToken.Close()
	var checkableToken windows.Token
	err = windows.DuplicateTokenEx(token, windows.TOKEN_QUERY | windows.TOKEN_IMPERSONATE, nil, windows.SecurityIdentification, windows.TokenImpersonation, &checkableToken)
	if err != nil {
		return false, err
	}
	defer checkableToken.Close()
	isMember, err := checkableToken.IsMember(someSID)
	return isMember && err == nil, nil

This is the same flow that's used by, for example, shell32's internal
_LUAIsTokenAdmin function.

However, this all fails unless the original token is opened with
duplicate access. So this commit adjusts OpenCurrentProcessToken to do
the right thing.

Change-Id: I18efdfde43097ea9d10758018b0df132fba819f5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192337
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Simon Rozman <simon@rozman.si>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-30 14:18:01 +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
Jason A. Donenfeld
19e00faab6 windows: add mutex management functions
Indeed Go has mutexes of its own, but these are considerably
different from the native Windows ones, that can work across processes
and be put in various namespaces. They're an essential part of Windows
systems programming and important for interfacing with various external
interfaces.

Change-Id: I03987800ed1c134442321678c2c7d7aa359ecb36
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192497
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-30 02:32:55 +00:00
Tobias Klauser
5fe476d890 unix: use bits.OnesCount64 instead of local copy
The local copy of bits.OnesCount64 was added for compatibility with Go
1.8 and earlier in CL 86477. Go 1.8 is no longer supported and go.mod
requires Go 1.12, so drop the local copy and use bits.OnesCount64.

Change-Id: Ieb77f0cef5f8f206b74ca737449efdcfe1949d44
Reviewed-on: https://go-review.googlesource.com/c/sys/+/192357
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-08-29 20:48:30 +00:00
Jason A. Donenfeld
c7b8b68b14 windows: add Windows directory accessors
These are useful for the same reason that the already existing
GetSystemDirectory is.

Change-Id: I3041ce6cbeb66a4f8a5960fbaf39381c8c9c80d6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/191837
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-26 19:00:57 +00:00
Jason A. Donenfeld
acd9dae8e8 windows: allow re-enabling priority boost
The Go runtime disables priority boosting because it interferes with the
scheduler timer threads in some cases. But some apps might want to
re-enable it for specific reasons, so this commit adds the function to
do so.

Change-Id: Ida68b9f2b188560b46c322197461dd06453329e2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/191839
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-08-26 16:37:24 +00:00
Jason A. Donenfeld
fb81701db8 windows: allow retrieving true version with RtlGetNtVersionNumbers
While RtlGetVersion was added so that users can get the Windows version
that isn't affected by manifesting, RtlGetVersion is still stubbed out
by the application compatibility layer (aclayers.dll and apphelp.dll)
for certain processes, such as msiexec.exe, rendering these functions
useless for actually determining the underlying operating system. This
matters in the case of msiexec.exe using a custom action DLL to install
a kernel driver, which of course is version specific. This is also
useful, it turns out, for the C runtime library, in which Microsoft uses
this function too. It's existed as a stable interface since Windows XP,
has Wine support, and is used in a decent amount of software.

Change-Id: If391e43bc6d798eff6803d5a7aa6a179f2b31d88
Reviewed-on: https://go-review.googlesource.com/c/sys/+/188119
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-25 16:06:03 +00:00
Tobias Klauser
fde4db37ae unix/linux: update Dockerfile to glibc 2.30
Change-Id: I4fd358388c46b4c2e8a4081640315db2313e585f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/189438
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2019-08-13 06:44:41 +00:00
Elias Naur
4e8604ab3a unix: disable ptrace on iOS
The ptrace system call is blocked by the App Store.

Updates golang/go#31628

Change-Id: I88977cb2f0892661a7221bc822dd513a951cbf67
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182317
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2019-08-12 17:24:37 +00:00
Tonis Tiigi
9eafafc0a8 unix: fix epoll_event padding on riscv64
Change-Id: I88bccf0e671d350f8f57ac4d277adf4081054729
GitHub-Last-Rev: 3302142611
GitHub-Pull-Request: golang/sys#40
Reviewed-on: https://go-review.googlesource.com/c/sys/+/189877
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-12 07:30:06 +00:00
utkarsh-extc
51ab0e2dea windows: add support for automatic delayed start in windows service
Change-Id: Iad33ea0f6627ac98c89dbaab0b41b3dd724c3163
GitHub-Last-Rev: 8764fdbd32
GitHub-Pull-Request: golang/sys#36
Reviewed-on: https://go-review.googlesource.com/c/sys/+/187198
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-08-04 05:38:45 +00:00
smasher164
cbf593c0f2 unix: remove nacl build tag from dirent code
Although CL 128110043 had deleted nacl from x/sys/unix, CL 38758
accidentially introduced its build tag in dirent.go when copying
over stdlib syscall code, which this CL removes.

Fixes golang/go#33391.

Change-Id: Iad6fe9818e38f14548eecdc078392865a60e4685
Reviewed-on: https://go-review.googlesource.com/c/sys/+/188361
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-08-01 04:14:06 +00:00
Matt Layher
1393eb0183 unix: fix several staticcheck issues
Resolves a number of issues, except for the clen function being
unused on Linux, as that would require a larger refactor which
probably isn't strictly necessary.

$ staticcheck .
affinity_linux.go:94:8: const m3 is unused (U1000)
affinity_linux.go:95:8: const m4 is unused (U1000)
sendfile_test.go:41:2: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (SA2002)
sendfile_test.go:47:6: this value of err is never used (SA4006)
syscall_linux_test.go:519:21: should use time.Since instead of time.Now().Sub (S1012)
syscall_linux_test.go:530:21: should use time.Since instead of time.Now().Sub (S1012)
syscall_test.go:66:2: this value of ts is never used (SA4006)
syscall_test.go:67:2: this value of ts is never used (SA4006)
syscall_unix.go:88:6: func clen is unused (U1000)

Change-Id: I2611b4559339cea758b5da27ea1f36fb8cc2df3f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/188037
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-07-30 18:39:49 +00:00
Tianon Gravi
fc99dfbffb windows: add CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, and CTRL_SHUTDOWN_EVENT
This is part of the changes necessary to allow simulated `SIGTERM` on Windows (these are the relevant events for `SetConsoleCtrlHandler` that would correspond to `SIGTERM` on Unix).

See https://docs.microsoft.com/en-us/windows/console/handlerroutine for a good documentation source upstream to confirm these values.

Updates golang/go#7479

(This exists under `src/cmd/vendor/golang.org/x/sys/windows/types_windows.go` in https://github.com/golang/go, so I figured I would start here and follow up with a https://github.com/golang/go PR/CL if reviewers here were amenable to this half.)

Change-Id: If3d0175bb889e4eddca838ef765faf5e379285ea
GitHub-Last-Rev: 7db84d6cd3
GitHub-Pull-Request: golang/sys#37
Reviewed-on: https://go-review.googlesource.com/c/sys/+/187578
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-07-26 09:17:11 +00:00
CarlosEDP
94b544f455 unix: add riscv64 tag to endian_little.go
Update golang/go#27532

Change-Id: I302f7db344e7704000b6e0c976519965b4f6a4ee
GitHub-Last-Rev: a18db686b2
GitHub-Pull-Request: golang/sys#38
Reviewed-on: https://go-review.googlesource.com/c/sys/+/187637
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-07-26 00:22:31 +00:00
Tobias Klauser
fae7ac547c unix: add constants and types to work with Linux loop devices
Change-Id: I0996df39a561b50822a6e42e770d96421d6b4965
Reviewed-on: https://go-review.googlesource.com/c/sys/+/185498
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-07-12 06:29:09 +00:00
Tobias Klauser
6ec70d6a55 unix: update Dockerfile to Linux 5.2 and Go 1.13beta1
Change-Id: I1a63f6ae5fe6b8b6fb4f493837b12dbe3c2860d4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/185497
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-07-10 14:34:15 +00:00
Tobias Klauser
04f50cda93 unix: add missing dirent* helper functions on aix
These are needed by ParseDirent and were missing in CL 183897.

Change-Id: I5b340fea9c0dc1b65b717b0d3cfd8cbb40d3cae9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183997
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-26 22:19:50 +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
e93b963712 unix: use ParseDirent in testGetdirentries
Use ParseDirent to get the directory entries instead of manually parsing
them. This fixes the test on dragonfly where type Dirent doesn't have a
Reclen member.

Manually tested on darwin, dragonfly and freebsd.

Change-Id: I234c6aff78243fec8bba8784c1d4948fbbb4d027
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183226
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:14 +00:00
Tobias Klauser
d432491b91 unix: fix nil pointer dereference in Getdirentries on 32-bit freebsd 12
Don't attempt to dereference basep if it's nil, just pass it to
getdirentries_freebsd12 as is.

Change-Id: I043a9ee9262e6333c35fd9ecc52694c8fd2de9f6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183223
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-21 20:38:18 +00:00
Tobias Klauser
4d873483be unix: add missing import in readdirent_getdirentries.go
CL 182321 missed this and the trybots didn't catch it because they
neither test darwin nor dragonfly.

Change-Id: I6093805e702d528dae9035a5acf827099e0c2eaa
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183222
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-21 19:03:02 +00:00
Yuval Pavel Zholkover
a26fa11ef6 unix: fix Getdirentries emulation using Getdents on netbsd, openbsd
CL 182319 used the wrong shift offset, correct and enable the TestGetdirentries.

Change-Id: I45d8d420a071fd79fa1b37642b984d80943f492b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183221
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-21 18:44:11 +00:00
Tobias Klauser
d6ba46b060 unix: add test for Getdirentries
Copied and adapted from the respective test in std syscall.

Change-Id: Ia35864e201c8b628dfc21a8da79305d5741d4acc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183219
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-21 18:37:10 +00:00
Tobias Klauser
8f4f963083 unix: merge implementation for ReadDirent
Provide common implementation for ReadDirent based on Getdents for
aix, *bsd and linux.

Add Getdents on aix as a wrapper around getdirent.

Keep the implementation for ReadDirent based on Getdirentries for
darwin and dragonfly.

Change-Id: I09094156a1452118ba48af4f14dfe44b1ab745d3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182321
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-06-21 18:36:46 +00:00
Tobias Klauser
943d5127bd unix: add support to get/set Linux capabilities
Add wrappers for Getcap/Setcap on Linux as well as some related types
and consts.

Change-Id: I07764c2e64717214850ea3cbdc238e313d1e38c4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183218
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-21 15:33:39 +00:00
Tobias Klauser
06bbe82148 unix: correctly rename Val member in Sigset_t on freebsd
The generated name X__bits should be changed to Val to match the type on
Linux. This was done manually in CL 179099 when Sigset_t was added for
freebsd. Modify mkpost.go to do it, so future changes won't revert the
rename.

Change-Id: I0ce135cbd8d03648a1576244d9c977b39c8f5889
Reviewed-on: https://go-review.googlesource.com/c/sys/+/183220
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-21 13:41:30 +00:00
rayrapetyan
bf70e46780 unix: add ptrace support for FreeBSD
Change-Id: Iaf95e3e7bd3d33ad7e214c45ed87b9e967b16631
GitHub-Last-Rev: e0308dc7ad
GitHub-Pull-Request: golang/sys#34
Reviewed-on: https://go-review.googlesource.com/c/sys/+/179099
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-21 06:25:56 +00:00
Tobias Klauser
6f217b454f unix: add AT_SYMLINK_FOLLOW const on openbsd
Change-Id: I60d7ce4a06e5a016cbb9fbf773a34748a5fd96f5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182899
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-20 07:01:43 +00:00
Tobias Klauser
6f551f7d2b unix: add AT_SYMLINK_FOLLOW const on netbsd
Change-Id: I6f6d9534389800b6f245021db051f96e90411173
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182897
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2019-06-20 07:01:26 +00:00
Jason A. Donenfeld
e40ef342dc windows: make CoTaskMemFree public
It's a useful function for people doing things with OLE32 from
elsewhere.

Change-Id: Id729d1c2b382ab4c097a06fb73448e671c0ad2f0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182157
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-06-19 22:31:25 +00:00
Gernot Vormayr
17bc6164aa unix: remove net dependency
According to godoc x/sys/unix is supposed to be a base for packages 'such
as "os", "time" and "net"'[1]. If we ever plan to make net a dependency
on x/sys/unix, this would lead to a circular dependency.

[1] https://godoc.org/golang.org/x/sys/unix

Change-Id: I3e2a62674148afd7e4f6db6acc3a364684b31379
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182320
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-19 18:30:51 +00:00
Jason A. Donenfeld
516e3c2063 windows: allow determining real version number
Other functions, like GetVersion(), will lie about the OS version
depending on various win32 and manifest compatibility shims in place.
Calling RtlGetVersion is the proper way to retrieve the true OS version.

Change-Id: I2bd6d097dd763df51617cd825dc0ad300abf6212
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182718
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2019-06-18 15:50:05 +00:00
Yuval Pavel Zholkover
15dcb6c006 unix: fix Getdirentries emulation using Getdents on netbsd, openbsd
Call Seek if basep is not nil to read the current dir offset.
Return EIO error if the offset doesn't fit into a 32-bit uintptr.
Make Getdents public.

Update golang/go#32498

Change-Id: Idfbc48d3fc3a6cc8a979242681e8882d39998285
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182319
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-06-16 12:48:12 +00:00
Yuval Pavel Zholkover
b47fdc9379 unix: change the mksysnum master to point to stable/11 on freebsd
Add a COMPAT10 directive to mksysnum.go to keep generating SYS_PIPE.

Updates golang/go#27619

Change-Id: Ifb54a812baf79c9426ce864bb0ef0e66b19d7f3b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182318
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-06-14 16:08:38 +00:00
Takuto Ikuta
d442b75600 windows: rename some arguments to follow MSDN
This is followup for CL 182097.

Change-Id: I55227381148dc5f83e185fafc294077b7a10df39
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182218
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
2019-06-14 08:40:37 +00:00
Jason A. Donenfeld
5ed2794edf windows: allow looking up well-known folder paths
This adds the recommended API for determining well-known folder paths,
such as where to place application configuration data. The MSDN
documentation mentions an optimization for the "current user" by passing
NULL as the token, so we provide both variants.

Updates golang/go#32248

Change-Id: I4a2d5d833543e6a0ba8f318944dd6493a0ec31d3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/181637
Reviewed-by: Jason Donenfeld <Jason@zx2c4.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-13 12:46:09 +00:00
Takuto Ikuta
ab3f67ed27 windows: add OpenThread function
ref:
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-openthread

Change-Id: I4ba1d48603581e93c2f5cd9798f8ef067b714753
Reviewed-on: https://go-review.googlesource.com/c/sys/+/182097
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-06-13 10:11:56 +00:00
Takuto Ikuta
914ada52e9 windows: add GetProcessId function
ref:
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-getprocessid

Document does not say anything about return value, but when I use 0 for HANDLE, GetProcessId
returns 0 with ERROR_INVALID_HANDLE from GetLastError().

Change-Id: Ib6782ccd5a4917e93ddbcf18c533921b12c67e3b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/180924
Reviewed-by: Marc-Antoine Ruel <maruel@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-06-13 09:49:25 +00:00
Keith Randall
93c9922d18 unix: fix Getdirentries on 32-bit freebsd 12
On freebsd 12, the system call for getdirentries writes 64 bits to
*basep, even on 32-bit systems. Accomodate that by providing a uint64
to the system call and copy the base to/from that uint64.
The uint64 seems to be a virtual file offset, so failing if the high
bits are not zero should be fine for reasonable-sized directories.

Update golang/go#32498

Change-Id: I4451894aff4e353c9f009c06ad2fdd5578dfd9f8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/181500
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-06-10 20:04:19 +00:00
Takuto Ikuta
1e42afee0f windows: expose GetCurrentProcessId function
Change-Id: I537bce4415871f0d4669398bd72e4eb7c9c03481
Reviewed-on: https://go-review.googlesource.com/c/sys/+/180921
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-06-10 08:10:24 +00:00