Commit graph

489 commits

Author SHA1 Message Date
jim price
6ab04b5941 std.os: Allow write functions to return INVAL errors
In Linux when interacting with the virtual file system when writing
in invalid value to a file the OS will return errno 22 (INVAL).

Instead of triggering an unreachable, this change now returns a
newly introduced error.InvalidArgument.
2023-03-06 15:59:18 -05:00
Andrew Kelley
8558983c86 std.os.abort: take advantage of @trap 2023-03-05 17:29:28 -07:00
jim price
a63134a4a5 std.os: Add DeviceBusy as a possible write error
In Linux when writing to various files in the virtual file system,
for example /sys/fs/cgroup, if you write an invalid value to a file
you'll get errno 16.

This change allows for these specific cases to be caught instead of
being lumped together in UnexpectedError.
2023-03-05 17:56:44 +02:00
Andrew Kelley
bb5006d728 std: add fchmodat
Also add `std.fs.has_executable_bit` for doing conditional compilation.

This adds the linux syscalls for chmod and fchmodat, as well as the
extern libc function declarations.

Only `fchmodat` is added to `std.os`, and it is not yet added to std.fs.
2023-03-03 02:37:45 -05:00
Jonathan Marler
dafefe9c9d use std_options for keep_sigpipe and existence of SIG.PIPE to check for support 2023-02-18 11:49:15 -07:00
Jonathan Marler
0a8fe34b11 add test to ignore sigpipe 2023-02-17 15:25:36 -07:00
Jonathan Marler
c02ced4d34 ignore SIGPIPE by default 2023-02-17 09:08:41 -07:00
Veikka Tuominen
7199d7c777 split @qualCast into @constCast and @volatileCast 2023-02-15 01:43:57 +02:00
Veikka Tuominen
f16c10a86b implement @qualCast 2023-01-30 18:55:57 +02:00
zigster64
2b27bc2c65 On BrokenPipe error during os.sendfile - return error rather than unreachable 2023-01-28 18:27:43 -05:00
Takeshi Yoneda
ce20ebb50c wasi: remove unnecessary breakpoint() in abort
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2023-01-26 19:14:36 +01:00
Andrew Kelley
ac28bedbee
Merge pull request #14418 from ifreund/assume-sentinel-sux
std: eliminate pointless meta.assumeSentinel() usage
2023-01-23 21:01:54 -05:00
Isaac Freund
faf2fd18d3
std: eliminate pointless meta.assumeSentinel() usage
This fixes a bug in std.net caused during the introduction of
meta.assumeSentinel due to the unfortunate semantics of mem.span()

This leaves only 3 remaining uses of meta.assumeSentinel() in the
standard library, each of which could be a simple @ptrCast([*:0]T, foo)
instead. I think this function should likely be removed.
2023-01-23 12:19:53 +01:00
Jan Philipp Hafer
55e879d2ed std.os.windows: add possible error NETNAME_DELETED of ReadFile
Closes #13631
2023-01-23 02:07:12 -05:00
mlugg
d3599ec73c std: implement os.mprotect on Windows 2023-01-20 03:33:35 +02:00
Andrew Kelley
f4d6b37068 Package: handle Windows PathAlreadyExists error code
Unfortunately, error.AccessDenied is ambiguous on Windows when it is
returned from fs.rename.
2023-01-11 17:54:34 -08:00
Andrew Kelley
c9ef277fa7
Merge pull request #13980 from ziglang/std.net
networking: delete std.x; add std.crypto.tls and std.http.Client
2023-01-03 02:43:50 -05:00
Michael Dusan
7798af7461
dragonfly: pass test: lib/std/std.zig 2023-01-02 19:18:33 -05:00
Michael Dusan
e752606464
netbsd: getFdPath: F_GETPATH implementation 2023-01-02 19:18:33 -05:00
Michael Dusan
7da9348637
dragonfly: getFdPath: F_GETPATH implementation 2023-01-02 19:18:33 -05:00
Michael Dusan
7f012eef0b
freebsd: memfd_create: < 13.0 version check
- add conditional compile error
- add conditional skip test
2023-01-02 19:18:33 -05:00
Michael Dusan
bd071c98a5
freebsd: getFdPath: handle NameTooLong 2023-01-02 19:18:33 -05:00
Michael Dusan
537624734c
freebsd: getFdPath: < 13.1 fallback impl 2023-01-02 19:18:32 -05:00
Michael Dusan
4cdbde55b4
macos: getFdPath: handle E.NOSPC
- per darwin-xnu source, fcntl F_GETPATH will return ENOSPC when path
  exceeds either user-supplied buffer or system MAXPATHLEN
- macOS does not document this (and other) possible errno values
2023-01-02 19:18:32 -05:00
Andrew Kelley
b3c8c383bb std.os: add missing handling of ECONNRESET in readv 2023-01-02 16:57:16 -07:00
Andrew Kelley
cd0d514643 remove the experimental std.x namespace
Playtime is over. I'm working on networking now.
2023-01-02 16:57:15 -07:00
Ryan Liptak
6e22b63edb windows: Extract RtlEqualUnicodeString usage into to a helper function 2022-12-17 22:06:47 -08:00
Jakub Konka
b27b17e253
Merge pull request #13935 from ziglang/mach-tasks
darwin: expose more Mach primitives, expose wrapped ptrace, and allow starting suspended for posix_spawn
2022-12-14 17:42:02 +01:00
Tom Maenan Read Cutting
d0eef26687 Add 0-length buffer checks to os.read & os.write
This helps prevent errors related to undefined pointers being passed
through to some OS apis when slices have 0 length.

Tests have also been added to catch these cases.
2022-12-12 15:10:59 -05:00
Takeshi Yoneda
78ea270cc6
wasi: fixes os.isatty on type mismatch (#13813) 2022-12-11 03:44:38 -05:00
Jakub Konka
35e3069ab7 darwin: expose ptrace with errno handling 2022-12-10 23:36:36 +01:00
Andrew Kelley
50eb7983cd remove most conditional compilation based on stage1
There are still a few occurrences of "stage1" in the standard library
and self-hosted compiler source, however, these instances need a bit
more careful inspection to ensure no breakage.
2022-12-06 20:38:54 -07:00
Andrew Kelley
b7b905d227 add behavior test for while(true) not needing else unreachable
closes #707
2022-12-06 17:57:27 -07:00
Andrew Kelley
e73170f972 std: fix WASI regressions
This branch largely reverts 58f961f4cb. I
would like to revisit the proposal to modify the standard library in
this way and think more carefully about it before adding isAbsolute()
checks everywhere.
2022-12-06 12:15:05 -07:00
Andrew Kelley
d5312d53a0 WASI: remove absolute path emulation from std lib
Instead of checking for absolute paths and current working directories
in various file system operations, there is one simple solution: allow
overriding `std.fs.cwd` on WASI.

os.realpath is back to causing a compile error when used on WASI. This
caused a compile error in the Sema handling of `@src()`. The compiler
should never call realpath, so the commit that made this change is
reverted (95ab942184). If this breaks
debug info, a different strategy is needed to solve it other than using
realpath.

I also removed the preopens code and replaced it with something much
simpler. There is no longer any global state in the standard library.

Additionally-
 * os.openat no longer does an unnecessary fstat on WASI when O.WRONLY
   is not provided.
 * os.chdir is back to causing a compile error on WASI.
2022-12-06 12:15:04 -07:00
Cody Tapscott
a0af3c7a19 std.os: Fix std.os.chdir for WASI
Test coverage was lacking for chdir() on WASI, allowing this to
regress.

This change makes os.chdir() compile again, and improves the test
logic to use our standard CWD support for WASI.
2022-11-26 22:06:15 +02:00
Ali Chraghi
aea617c60b std.os: take advantage of the freebsd's copy_file_range 2022-11-05 15:43:39 -04:00
Nameless
40e84a27d6
change uefi packed structs to new integer backed syntax (#13173)
* std.os.uefi: integer backed structs, add tests to catch regressions

device_path_protocol now uses extern structs with align(1) fields because
the transition to integer backed packed struct broke alignment

added comptime asserts that device_path_protocol structs do not violate
alignment and size specifications
2022-10-30 15:08:32 -04:00
daurnimator
c0c8ee5ae9 Add reboot syscall
Only linux for now
2022-10-27 20:39:35 -04:00
Ali Chraghi
ca27055cda all: rename @maximum to @max and @minimum to @min 2022-10-18 14:15:16 +03:00
Naoki MATSUMOTO
059e397ffc std.os: handle error.UnreachableAddress in send() 2022-10-17 13:10:23 +02:00
Jens Goldberg
1459231624 fix setsockopt returning ENODEV 2022-10-17 12:55:12 +02:00
Ali Chraghi
5127dae7a2 std.os: fix execv* doc comment 2022-10-16 11:38:22 -04:00
Andrew Kelley
c289794f0d nvptx: add TODO comment regarding abuse of llvm builtins 2022-10-15 10:50:02 -07:00
Guillaume Wenzek
24c749473a implement os.abort and panic for cuda 2022-10-15 10:39:19 -07:00
Marijn Stollenga
3a9344d8fc Return invalid argument in sendto instead of unreachable, since this can happen with user-side errors 2022-10-13 13:10:29 +02:00
cod1r
7b32aacbaf fix ChildProcess crash when PATH is empty. 2022-09-15 22:54:17 -04:00
John Schmidt
36f4f32fad
Add AFNOSUPPORT error to bind (#12560) 2022-09-01 15:13:07 -05:00
Motiejus Jakštys
9038528187 copy_file_range: fix zigification of TXTBSY
From `copy_file_range(2)` errors:

    ETXTBSY
           Either fd_in or fd_out refers to an active swap file.

Same error will be used in the upcoming `ioctl_ficlonerange(2)`:

    ETXTBSY
           One of the files is a swap file.  Swap files cannot share storage.
2022-08-26 15:36:40 +03:00
Andrew Kelley
5db80a051f Revert "std.os: add INVALID_SOCKET (#12081)"
This reverts commit 0f01e812ff.

This does not belong in `std.posix`, and it is already provided at
`std.os.windows.ws2_32.INVALID_SOCKET`.

See related issue #5019.
2022-08-23 21:30:23 -07:00