254 Commits

Author SHA1 Message Date
Andrew Kelley
5c16022c81 rename WaitpidRet to WaitPidResult 2020-10-16 18:14:39 -07:00
stf
3921cb0d8d std.os.waitpid: also return pid of child
closes #6581
2020-10-16 17:26:50 -07:00
Vignesh Rajagopalan
2ab0c7391a Rename .macosx to .macos 2020-10-12 18:56:25 -04:00
Andrew Kelley
76a195473d
Merge pull request #6516 from LemonBoy/fastfilecopy
std: Make file copy ops use zero-copy mechanisms
2020-10-08 20:14:47 -04:00
LemonBoy
03762da2af New review round 2020-10-07 11:13:26 +02:00
LemonBoy
1f7ec0de70 Address review comments & fix compilation errors 2020-10-06 11:57:23 +02:00
LemonBoy
a419a1aabc Move copy_file to fs namespace
Now it is a private API.
Also handle short writes in copy_file_range fallback implementation.
2020-10-06 09:38:59 +02:00
xackus
1b4296831a simplify api and add smoke test 2020-10-04 23:57:49 +02:00
xackus
4ec26be424 implement {get, set}rlimit for linux 2020-10-04 23:56:10 +02:00
LemonBoy
8b4f5f039d Alternative strategy to avoid calling stat()
This is an optimization as it avoids an extra syscall, but it's also a
workaround for fstat being not available on Windows.
2020-10-03 19:51:22 +02:00
LemonBoy
0f248e0988 std: Make file copy ops use zero-copy mechanisms
Use copy_file_range on Linux (if available), fcopyfile on Darwin,
sendfile on *BSDs (and on Linux kernels without copy_file_range).
2020-10-03 12:31:17 +02:00
Loris Cro
a2074c1ec3 fix symlink path not being resolved in darwin
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-10-02 17:06:29 +02:00
Loris Cro
8d01133bd0 update doc comments
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-25 18:42:24 +02:00
Loris Cro
c196c27af8 recvfrom
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
419aea54cb sendto
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
7fec5b3def pwritev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:41 +02:00
Loris Cro
7a07c62a07 pwrite
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:21 +02:00
Loris Cro
18f6629bd8 writev
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:06:03 +02:00
Loris Cro
9075f8e5a1 write
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:05:41 +02:00
Loris Cro
59ecdaea12 preadv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:43 +02:00
Loris Cro
bd9f2369d5 pread
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:04:05 +02:00
Loris Cro
bc35435ca6 readv
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:03:12 +02:00
Loris Cro
08364ac773 read
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 22:00:55 +02:00
Loris Cro
730428bfd6 connect
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 21:56:27 +02:00
Loris Cro
e85c89630e accept
Signed-off-by: Loris Cro <kappaloris@gmail.com>
2020-09-24 21:56:27 +02:00
Ryan Liptak
fbde15fdf4 Fix compile error in os.renameatW
Introduced in 5e3fa0e94f947c632aa584b9e13bfa2fe241fae1

Whoops!
2020-09-17 18:49:06 -04:00
Ryan Liptak
5e3fa0e94f Add rename to std.fs API
- Moves fs.rename functions to fs.renameAbsolute to match other functions outside of fs.Dir
- Adds fs.Dir.rename that takes two paths relative to the given Dir
- Adds fs.rename that takes two separate Dir's that the given paths are relative to (for renaming across directories without having to make the second path relative to a single directory)
- Fixes FileNotFound error return in std.os.windows.MoveFileExW
- Returns error.RenameAcrossMountPoints from renameatW
  + Matches the RenameAcrossMountPoints error return in renameatWasi/renameatZ
2020-09-17 17:22:26 -04:00
LemonBoy
5e50d145d9 std: Limit the read/write size on Darwin
It turns out that the kernel won't read or write more than 0x7fffffff
bytes in a single call, failing with EINVAL when trying to do so.

Adjust the limit and curse whoever is responsible for this.

Closes #6332
2020-09-13 16:31:21 -04:00
Isaac Freund
744b73ab46
std: add prctl wrapper to std.os 2020-09-11 22:32:23 +02:00
Isaac Freund
bb9773f695 std: fix errorset of std.os.seteuid/setegid 2020-09-10 15:41:21 -04:00
Veikka Tuominen
41bbadbb9a
Merge pull request #6246 from Vexu/field
Remove deprecated fields on `type`
2020-09-05 13:58:02 +03:00
Andrew Kelley
1034459170
Merge pull request #6243 from ifreund/uid-gid-cleanup
std: clean up usage of uid_t/gid_t, add seteuid/setegid to std.os
2020-09-03 18:05:59 -04:00
Andrew Kelley
39a80cf59e
Merge pull request #6238 from Aransentin/master
Add the "sync" family of functions
2020-09-03 14:07:36 -04:00
Kenta Iwasaki
50e3906951
os: return error.SocketNotListening for EINVAL on accept (#6226) 2020-09-03 13:57:08 -04:00
Vexu
1df0f3ac24
update uses of deprecated type field access 2020-09-03 18:10:40 +03:00
Isaac Freund
d0d6647fdb
std: add seteuid/setegid to std.os
Currently these are only implemented for linux.
2020-09-03 15:22:43 +02:00
Isaac Freund
e8a2aecd2f
std: fix linux uid_t, use uid_t/gid_t in std.os
- correct uid_t from i32 to u32 on linux
- define uid_t and gid_t for OSes missing definitions
- use uid_t/gid_t instead of plain u32s throughout std.os
2020-09-03 15:08:37 +02:00
Aransentin
25f6663304 Add the sync functions 2020-09-02 22:16:40 +00:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Andrew Kelley
b1c7334355
Merge pull request #5745 from lun-4/ebadf-error
map EBADF to error values for read and write
2020-08-19 23:46:22 -04:00
Andrew Kelley
ae2c88754d std: signalfd: fix the types of things; add test 2020-08-17 16:19:57 -07:00
Luna
2deb07a001 rename signalfd4 to signalfd 2020-08-17 16:05:35 -07:00
Jakub Konka
3e2e6baee5 Add std.os.getFdPath and std.fs.Dir.realpath
`std.os.getFdPath` is very platform-specific and can be used to query
the OS for a canonical path to a file handle. Currently supported hosts
are Linux, macOS and Windows.

`std.fs.Dir.realpath` (and null-terminated, plus WTF16 versions) are
similar to `std.os.realpath`, however, they resolve a path wrt to this
`Dir` instance.

If the input pathname argument turns out to be an absolute path, this
function reverts to calling `realpath` on that pathname completely
ignoring this `Dir`.
2020-08-13 07:08:39 +02:00
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04:00
Jakub Konka
bdda8fa7a8 Redo GetFinalPathNameByHandle using DeviceIoControl
This commit reimagines `std.os.windows.GetFinalPathNameByHandle`
using `DeviceIoControl` to query the OS mount manager for the DOS
(symlink) paths for the given NT volume name. In particular,
it uses `IOCTL_MOUNTMGR_QUERY_POINTS` ioctl opcode to query the
manager for the available moount points.
2020-08-07 11:33:05 +02:00
Jakub Konka
747d46f22c Initial draft of GetFinalPathNameByHandle
This commit proposes an initial draft of `GetPathNameByHandle` function
which wraps NT syscalls and strives to emulate (currently only
partially) the `kernel32.GetFinalPathNameByHandleW` function.
2020-08-06 23:56:37 +02:00
Jakub Konka
4b0ab0c186
Apply suggestions from code review
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2020-08-02 19:36:49 +02:00
Jakub Konka
4d9eff4bdb Add prelim openW and openatW
Added POSIX functions targeting Windows pass `open` and `openat`
smoke tests.
2020-07-31 16:41:25 +02:00
Jakub Konka
8981b18fee Move delete file logic into windows.DeleteFile fn
This way, we can remove more `kernel32` calls such as `RemoveDirectoryW`
or `DeleteFileW`, and use `std.os.windows.DeleteFile` instead which
is purely NT-based.
2020-07-31 16:31:51 +02:00
Jakub Konka
66bbe4ec4c Refactor internal Win routines to reuse OpenFile
This covers mainly `ReadLink` and `CreateSymolicLink` functions.
2020-07-31 16:31:44 +02:00