aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os.zig
AgeCommit message (Collapse)Author
2022-09-01Add AFNOSUPPORT error to bind (#12560)John Schmidt
2022-08-26copy_file_range: fix zigification of TXTBSYMotiejus Jakštys
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-23Revert "std.os: add INVALID_SOCKET (#12081)"Andrew Kelley
This reverts commit 0f01e812ff054ea83661272bf0a96af228f2ffe3. 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-23std.os: add INVALID_SOCKET (#12081)yyny
This constant returns an invalid `socket_t` that can be used as a sentinel value.
2022-08-21Enable unexpectedErrno error tracing for stage2 LLVMJohn Schmidt
Stage2 seems to be able to handle this now.
2022-08-17libstd: do not follow symlinks in renameatWJakub Konka
This correctly mimicks POSIX behavior.
2022-08-11Merge pull request #12410 from ifreund/sig-err-dfl-ign-fixAndrew Kelley
std: fix definition of SIG_IGN, SIG_DFL, etc.
2022-08-11std: add missing error to windows.WriteFileAndrew Kelley
I encountered this error today when testing the self-hosted compiler on Windows.
2022-08-11std: fix definition of SIG_IGN, SIG_DFL, etc.Isaac Freund
POSIX specifies that the sa_handler field of the sigaction struct may be set to SIG_IGN or SIG_DFL. However, the current constants in the standard library use the function pointer signature corresponding to the sa_sigaction field instead. This may not cause issues in practice because the fields usually occupy the same memory in a union, but this isn't required by POSIX and there may be systems we do not yet support that do this differently. Fixing this also makes the Zig interface less confusing to use after reading the man page.
2022-08-11std: Don't pass undefined memory to the kernel in os.abort()Isaac Freund
2022-07-31Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watchRyan Liptak
From https://man7.org/linux/man-pages/man7/inotify.7.html > **IN_MASK_CREATE** (since Linux 4.18) > > Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.
2022-07-15std.fs: remove `OpenDirOptions.iterate`Veikka Tuominen
2022-07-15add FreeBSD support to std.os.getFdPathKim SHrier
This implementation uses the F_KINFO fcntl command added in FreeBSD 13 release. FreeBSD 12 users get a compile error. Co-authored-by: Stephen Gregoratto <dev@sgregoratto.me>
2022-07-14handle HOSTUNREACH for blocking and non-blocking connectsBill Nagel
2022-07-13AstGen: fix loop control flow applying to wrong loopAndrew Kelley
In the case of 'continue' or 'break' inside the 'else' block of a 'while' or 'for' loop. Closes #12109
2022-07-01Sema: validate deref operator type and valueVeikka Tuominen
2022-06-21std.os.execvpe: fix buffer overflowJonathan Marler
The NameTooLong check isn't taking the sentinel 0 into account which would result in a buffer overflow on the stack.
2022-06-06std.os.abort patch cleanupsAndrew Kelley
* move global into function scope * clarify comments * avoid unnecessary usage of std.atomic API * switch on error instead of `catch unreachable` * call linux.gettid() instead of going through higher level API and doing unnecessary casting
2022-06-06std.os.abort: ported signal handling from muslJan Philipp Hafer
* Document deviation from Linux man page, which is identical to musl. Man page wants always enabled user-provided abort handlers. Worst case logic bug, which this can introduce: + user disables SIGABRT handler to prevent tear down to last safe state + abort() gets called and enables user-provided SIGABRT handler + SIGABRT tears down to supposed last safe state instead of crash + Application, instead of crashing, continues * Pid 1 within containers needs special handling. - fatal signals are not transmitted without privileges, so use exit as fallback * Fix some signaling bits * Add checks in Debug and ReleaseSafe for wrong sigprocmask
2022-05-27math: make `cast` return optional instead of an errorAli Chraghi
2022-05-17std.os: add timerfd_create, timerfd_settime and timerfd_gettimeThiago Teodoro Pereira Silva
2022-05-16std.os: Add memfd_create for FreeBSDIsaac Freund
This is minorly breaking as e.g. std.os.linux.MFD_CLOEXEC is now std.os.linux.MFD.CLOEXEC.
2022-05-11Merge pull request #10595 from squeek502/getenvW-caseAndrew Kelley
os.getenvW: Fix case-insensitivity for Unicode env var names
2022-04-27std: replace usage of std.meta.bitCount() with @bitSizeOf()Isaac Freund
2022-04-16stdlib std.os: Improve wasi-libc parity for WASI CWD emulationCody Tapscott
Two major changes here: 1. We store the CWD as a simple `[]const u8` and lookup Preopens for every absolute or CWD-referenced file operation, based on the Preopen with the longest match (i.e. most specific path) 2. Preorders are normalized to POSIX absolute paths at init time. Behavior depends on the "cwd_root" parameter of `initPreopensWasi`: `cwd_root` is used for any Preopens that start with "." For example: "./foo/bar" - inits to -> "{cwd_root}/foo/bar" "foo/bar" - inits to -> "/foo/bar" "/foo/bar" - inits to -> "/foo/bar" `cwd_root` must be an absolute path. Using "/" as `cwd_root` gives behavior similar to wasi-libc.
2022-04-05zig fmt: remove trailing whitespace on doc commentsDamien Firmenich
Fixes #11353 The renderer treats comments and doc comments differently since doc comments are parsed into the Ast. This commit adds a check after getting the text for the doc comment and trims whitespace at the end before rendering. The `a = 0,` in the test is here to avoid a ParseError while parsing the test.
2022-04-04Pull elf magic string out to re-used constantTom Read Cutting
2022-03-19fix sigaction double paniczseri
Fixes #8357
2022-03-16std: introduce posix_spawn as an alt to fork-execJakub Konka
Currently, the new API will only be available on macOS with the intention of adding more POSIX systems to it incrementally (such as Linux, etc.). Changes: * add `posix_spawn` wrappers in a separate container in `os/posix_spawn.zig` * rewrite `ChildProcess.spawnPosix` using `posix_spawn` targeting macOS as `ChildProcess.spawnMacos` * introduce a `posix_spawn` specific `std.c.waitpid` wrapper which does return an error in case the child process failed to exec - this is required for any process that was spawned using `posix_spawn` mechanism as, by definition, the errors returned by `posix_spawn` routine cover only the `fork`-equivalent; `pre-exec()` and `exec()` steps are covered by a catch-all error `ECHILD` returned by `waitpid` on unsuccessful execution, e.g., no such file error, etc.
2022-03-13std+macho: revert and fix exposing Mach wrappers in std.os and std.cJakub Konka
2022-03-13std: fix imports for darwin specific flags and funcsJakub Konka
2022-03-13macos: add Mach task abstractionJakub Konka
`std.os.darwin.MachTask` wraps `mach_port_t` and can be used to issue kernel calls tied to the wrapped Mach kernel port/task.
2022-03-03stdlib std.os: Rename `RelativePath` to `RelativePathWasi`Cody Tapscott
2022-03-03stdlib WASI: Add realpath() support for non-absolute PreopensCody Tapscott
2022-03-03stdlib: Add emulated CWD to std.os for WASI targetsCody Tapscott
This adds a special CWD file descriptor, AT.FDCWD (-2), to refer to the current working directory. The `*at(...)` functions look for this and resolve relative paths against the stored CWD. Absolute paths are dynamically matched against the stored Preopens. "os.initPreopensWasi()" must be called before std.os functions will resolve relative or absolute paths correctly. This is asserted at runtime. Support has been added for: `open`, `rename`, `mkdir`, `rmdir`, `chdir`, `fchdir`, `link`, `symlink`, `unlink`, `readlink`, `fstatat`, `access`, and `faccessat`. This also includes limited support for `getcwd()` and `realpath()`. These return an error if the CWD does not correspond to a Preopen with an absolute path. They also do not currently expand symlinks.
2022-02-27std: rename `sched_yield` to `yield` and move it to `std.Thread`David John
2022-02-19os.getenvW: Fix handling of special `=`-prefixed env varsRyan Liptak
2022-02-19os.getenvW: Fix case-insensitivity for Unicode env var namesRyan Liptak
Windows does Unicode-aware case-insensitivity comparisons for environment variable names. Before, os.getenvW was only doing ASCII case-insensitivity. We can take advantage of RtlEqualUnicodeString in NtDll to get the proper Unicode case insensitivity.
2022-02-15Adds Linux support for POSIX file locking with fcntlAnthony Carrico
On Linux, locking fails with EAGAIN (vs. EACCES on other systems). This commit also adds FcntlErrors for EDEADLK and ENOLCK.
2022-02-14std.os: throw compile error for `argv` on Windowsominitay
On Windows, `argv` is not populated by start code, and instead left as undefined. This is problematic, and can lead to incorrect programs compiling, but panicking when trying to access `argv`. This change causes these programs to produce a compile error on Windows instead, which is far preferable to a runtime panic.
2022-02-11std: validate frame-pointer address in stack walkingm
2022-02-07std: fix doc comment typo in os.zigboofexxx
2022-01-31os,wasi: use wasi-libc if availableŽiga Željko
2022-01-23std: Add some missing termios types to c/linux.zig and os.zigjoachimschmidt557
2022-01-17remove `zig_is_stage2` from `@import("builtin")`Andrew Kelley
Instead use the standarized option for communicating the zig compiler backend at comptime, which is `zig_backend`. This was introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.
2022-01-02std.fs.rename: fix Windows implementationAndrew Kelley
The semantics of this function are that it moves both files and directories. Previously we had this `is_dir` boolean field of `std.os.windows.OpenFile` which required the API user to choose: are we opening a file or directory? And the other kind would either cause error.IsDir or error.NotDir. But that is not a limitation of the Windows file system API; it was self-imposed. On Windows, rename is implemented internally with `NtCreateFile` so we need to allow it to open either files or directories. This is now done by `std.os.windows.OpenFile` accepting enum{file_only,dir_only,any} instead of a boolean.
2021-12-21os: disable unexpected error tracing on stage 2 buildsRobin Voetter
The self-hosted compiler cannot yet deal with the print function that this field enables. It is not critical, however, and allows us to remove formatting from the list of neccesary features to implement to get the page allocator working.
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-12-15std.os: fix error codes for execveAndrew Kelley
execve can return EBADLIB on Linux. I observed this when passing an x86_64 interpreter path to qemu-i386. This error code is Linux and Solaris-only. I came up with an improved pattern for dealing with OS-specific error codes.
2021-12-06std.os: handle ETXTBSY from open()Andrew Kelley