This was the intention from the start, but due to a logic error in the
handling of slices the implementation only handled minimum 8 character
strings.
This commit also improves the tests.
Change-Id: I6b0ed00bbd8a2faf90ca4a3ebe6218d3c5d6e8bf
GitHub-Last-Rev: 5b6dbc0682
GitHub-Pull-Request: golang/sys#77
Reviewed-on: https://go-review.googlesource.com/c/sys/+/248778
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Some systems (e.g. the linux-arm and linux-arm64-packet builders) return
EPERM instead of ENOSYS on unimplemented syscalls. Fall back to the
existing glibc-like implementation in Faccessat in this case as well.
This fixes tests on the linux-arm and linux-arm64-packet builders after
CL 246537.
Change-Id: I7d7598f9694a2db19bd17e79f333d5de3a31c6e2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/246817
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The GODEBUG environment variable can be used to disable usage of
specific processor features of Go programs that use the sys/cpu package.
This is useful for testing and benchmarking different code paths that
are guarded by sys/cpu variable checks.
Use of processor features can not be enabled through GODEBUG.
To disable usage of AVX and SSE41 cpu features on GOARCH amd64 use:
GODEBUG=cpu.avx=off,cpu.sse41=off
The special "all" option can be used to disable all options:
GODEBUG=all=off
This aligns the support of GODEBUG for sys/cpu with existing support
for GODEBUG in the Go standard library package internal/cpu.
Fixesgolang/go#33963
Change-Id: I618b71af397bf06c57a49b2a300d032a16d05664
Reviewed-on: https://go-review.googlesource.com/c/sys/+/245237
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Linux kernel 5.8 added the faccessat2 syscall taking a flags argument.
Attempt to use it in Faccessat and fall back to the existing
implementation mimicking glibc faccessat.
Tested on Debian Buster with manually built Linux kernel 5.8
Suggested by Ian Lance Taylor.
Change-Id: Ia14f744a63dde7ff2dea34935cabc62937de9cb5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/246537
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
I noticed that we call syscall in servicemain without aligning stack.
That is against Windows rules, so align the stack as required.
I tried running this code with specifically non-aligned stack (I aligned
stack, and then subtracted 1 from SP) on my Windows 10 to test this
change. But it makes no difference on my Windows 10 PC - I built and run
golang.org/x/sys/windows/svc/example, and it runs successfully
regardless of stack alignment. But alignment might make difference on
other computers.
Maybe fixesgolang/go#40160
Change-Id: I351f7f730fba4aa6dc409a79de4ad737b4a0a7d4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/246317
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
These are Linux-specific system calls for efficiently reading and
writing memory in foreign processes.
A new RemoteIovec type is added for use in these wrappers, as Iovec's
Base field is a pointer, and creating invalid pointers is invalid in
Go.
Change-Id: I329501ab7b4df9d0aebe289369d3a5f77120af02
GitHub-Last-Rev: 262aabed02
GitHub-Pull-Request: golang/sys#74
Reviewed-on: https://go-review.googlesource.com/c/sys/+/243497
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
CL 223698 changed the types of the Fstypename, Mntfromname and Mntonname
fields of type Statfs_t on freebsd/{386,amd64,arm64}, but didn't do so
on freebsd/arm. Since reverting that change now would probably cause
more harm than good, at least make the type consistent on all supported
freebsd/$GOARCH combinations.
Change-Id: I66ba3cdb0290177898237a47d305abb9adc97954
Reviewed-on: https://go-review.googlesource.com/c/sys/+/239060
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Follow glibc's implementation and check secondary group memberships
using Getgroups.
No test since we cannot easily change file permissions when not running
as root and the test is meaningless if running as root.
Fixesgolang/go#39660
Change-Id: Idb841242cbd1d8859f4e3c2c26b64a5e9523f9a4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/238722
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This CL fixes unsafe casts to slices that are missing length or capacity.
Running tests with -d=checkptr enabled may panic on casting unsafe.Pointer to a static array of large predefined length, that is most likely much bigger than the size of the actual array in memory. Checkptr check is not satisfied if slicing operator misses length and capacity arguments `(*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:]`, or when there is no slicing at all `(*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))`.
To find all potential cases I used `grep -nr ")(unsafe.Pointer(" ./windows`, then filtered out safe casts when object size is always static and known at compile time.
To reproduce the issue run tests with checkptr enabled `go test -a -gcflags=all=-d=checkptr ./windows/...`.
Updates golang/go#34972Fixesgolang/go#38355
Change-Id: I9dd2084b4f9fb7618cdb140fb2f38b56b6d6cc04
GitHub-Last-Rev: 73288ad18a
GitHub-Pull-Request: golang/sys#65
Reviewed-on: https://go-review.googlesource.com/c/sys/+/225418
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
The typos in the package godoc comment were pointed out in CL 231223
which added similar functionality to the main Go repository. Also
correct the name in the godoc comment for type String.
Change-Id: I69910f3e24b1222190e1adf7fc3d425f0006f96e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/231517
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
The regression test included in this change verifies that the type is,
in fact, equivalent, while allowing the actual header definitions to
avoid importing the (relatively heavy) "reflect" package itself.
This change is loosely based on Keyan Pishdadian's draft in CL 230557.
For golang/go#37805
Change-Id: I998c69cdeb852154cd66ab5fdaa542a6f19666a2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/231177
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
ubuntu:19.04 is not supported anymore and update repos are unavailable, so
build process on Linux just fails. Latest stable ubuntu:20.04 works fine.
Also, DEBIAN_FRONTEND=noninteractive env variable has been added to prevent
unneeded questions during installation of tzdata package.
Fixesgolang/go#38724
Change-Id: I2d7730d83fc051de2879d4f97fc7942090d2574c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/230577
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Follow the existing examples of the SockaddrTIPC and SockaddrL2TPIP{,6}
tests.
Handling of abstract socket addresses is different on linux than on
other platforms, thus these are currently linux-specific.
Change-Id: I66686d979e1dd317ab7a8a6dd85f98e670ad89b6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/228764
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
openat2 is a new syscall added to Linux 5.6. It provides a superset
of openat(2) functionality, providing a way to extend it in the future,
and (for now) adding flags telling the kernel how to resolve the path.
For more info on openat2, see https://lwn.net/Articles/803237/
A primitive test case is added to check that Openat2 works as
it should. Tested to skip on kernel 5.5 and pass on 5.6.
Change-Id: Ib8bbd71791762f043200543cecdea16d2fd3c81d
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reviewed-on: https://go-review.googlesource.com/c/sys/+/227280
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>