The fallback for systems that lack preadv() only filled the first
buffer.
This commit rectifies that to fill all (or at least as many as possible)
buffers.
Fixes: https://github.com/libuv/libuv/issues/2332
PR-URL: https://github.com/libuv/libuv/pull/2338
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
This commit add support for Haiku, an open-source operating system
inspired by BeOS.
PR-URL: https://github.com/libuv/libuv/pull/2301
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This was reported as a bug in November 2018 but it appears to be working
now. Add a regression test to ensure it stays that way.
Fixes: https://github.com/libuv/libuv/issues/2076
PR-URL: https://github.com/libuv/libuv/pull/2279
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Explicitly initialize uv_stat_t fields st_flags and st_gen when using
statx as uv__to_stat does when statx is not available. This makes
valgrind happier.
PR-URL: https://github.com/libuv/libuv/pull/2263
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jameson Nash <vtjnash@gmail.com>
Kernels > 4.11 support the statx() system call that lets one retrieve
the birth time of a file. Teach libuv about it.
Fixes: https://github.com/libuv/libuv/issues/2152
PR-URL: https://github.com/libuv/libuv/pull/2184
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
On Windows, `fs__open()` maps `UV_FS_O_DIRECT` to
`FILE_FLAG_NO_BUFFERING`.
When `access` is only `FILE_GENERIC_READ` this succeeds, but when
`access` is `FILE_GENERIC_WRITE` this returns an error:
```
0x00000057, ERROR_INVALID_PARAMETER, The parameter is incorrect.
```
The reason is that `FILE_GENERIC_WRITE` includes `FILE_APPEND_DATA`,
but `FILE_APPEND_DATA` and `FILE_FLAG_NO_BUFFERING` are mutually
exclusive:
```
FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE |
FILE_WRITE_DATA |
FILE_WRITE_ATTRIBUTES |
FILE_WRITE_EA |
FILE_APPEND_DATA |
SYNCHRONIZE
```
This incompatibility between access and attribute flags does not appear
to be documented by Microsoft for `FILE_FLAG_NO_BUFFERING` but it is
indirectly documented under [NtCreateFile](https://bit.ly/2rm5wRT):
```
FILE_NO_INTERMEDIATE_BUFFERING
The file cannot be cached or buffered in a driver's internal buffers.
This flag is incompatible with the DesiredAccess FILE_APPEND_DATA flag.
```
The solution is to remove `FILE_APPEND_DATA` from the access flags when
`FILE_FLAG_NO_BUFFERING` is set. Note that this does not prevent
appends, since `FILE_GENERIC_WRITE` also includes `FILE_WRITE_DATA`,
which in turn allows appends.
PR-URL: https://github.com/libuv/libuv/pull/2102
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
uv_fs_unlink would fail for read-only files with Archive attribute
cleared. This fixes this issue.
PR-URL: https://github.com/libuv/libuv/pull/1774
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit adds checks for fs request values when a call
fails with UV_EINVAL.
PR-URL: https://github.com/libuv/libuv/pull/1752
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit adds tests that pass bad options to uv_fs_copyfile(),
uv_fs_read(), and uv_fs_write(). These tests verify that the
asynchronous version of these functions do not hold the event
loop open on bad inputs.
Refs: https://github.com/nodejs/node/pull/18811
PR-URL: https://github.com/libuv/libuv/pull/1747
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reverted for breaking `test/parallel/test-child-process-cwd.js` from the
Node.js test suite. Instead of ENOENT when trying to remove a directory
that does not exist, it started failing with ENOTDIR.
This reverts commit 15f29dc08f.
PR-URL: https://github.com/libuv/libuv/pull/1717
Refs: https://github.com/nodejs/node/issues/18014
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Use RemoveDirectoryW() and remap ERROR_DIRECTORY from UV_ENOENT
to UV_ENOTDIR so that attempted removal of a non-directory produces
the right (and legible) error message.
Fixes: https://github.com/nodejs/node/issues/18014
PR-URL: https://github.com/libuv/libuv/pull/1698
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Added a check in uv__fs_buf_iter to detect partial reads and writes.
Partial reads and writes are looped until all data has been processed.
PR-URL: https://github.com/libuv/libuv/pull/640
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Include `<winioctl.h>` for the definition of `FSCTL_SET_REPARSE_POINT`
and define `ERROR_SYMLINK_NOT_SUPPORTED` if not already defined.
PR-URL: https://github.com/libuv/libuv/pull/1632
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Fixes uv_fs_stat and uv_fs_lstat returning EINVAL when invoked on a
non-symlink reparse point.
1. Only tries to read symlinks when invoked via lstat (do_lstat == 1).
Rationale is that only lstat can set S_IFLNK because when a file is
tested by stat, symlinks are resolved by the OS and the returned file
must be real. Note that broken symlinks fail at CreateFile.
FILE_ATTRIBUTE_REPARSE_POINT is used by filesystem drivers for purposes
besides symlinks, and uv_fs_stat fails when invoked on these files
because fs__readlink_handle returns ERROR_SYMLINK_NOT_SUPPORTED. By
ignoring the attribute in uv_fs_stat, these files are now handled
correctly.
2. Modifies the logic added to fs__stat_handle to fix#995 as follows:
A failed fs__readlink_handle on a file with a reparse point indicates
that the file is not a symlink. The fix for #995 added code to fall
through and behave as with a normal file in this case. However, this is
not correct because lstat had opened the file with
FILE_FLAG_OPEN_REPARSE_POINT, preventing the filesystem from acting
based on the reparse point contents.
The fix makes fs__stat_handle fail back to the higher level
fs__stat_impl, which sets do_lstat to 0 and re-opens the file without
FILE_FLAG_OPEN_REPARSE_POINT, allowing normal filesystem processing to
take place.
This is also a slightly cleaner solution as symlink fallback is only
handled in one place (fs__stat_impl) instead of two (fs__stat_impl and
fs__stat_handle).
Note that the error tested in the fix for #995,
ERROR_NOT_A_REPARSE_POINT, is not actually returned by Windows in the
case of a non-symlink reparse point. I attempted to reproduce the error
by repeating the test steps in the issue but failed. However, the the
fix logic is preserved out of caution.
3. Adds tests to fs-test.c for the above two changes.
Thorough testing requires some non-trivial setup - like an OSX computer
on the LAN or a custom filesystem driver - so these tests are left
commented out for manual invocation.
PR-URL: https://github.com/libuv/libuv/pull/1522
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
This commit introduces an INIT macro to file system functions on
Windows, similar to the one used on Unix platforms. The macro
checks for NULL requests, and returns UV_EINVAL in such
scenarios. This commit also adds support for passing NULL to
uv_fs_req_cleanup(). In this scenario, the function is a
no-op.
Fixes: https://github.com/libuv/libuv/issues/1508
PR-URL: https://github.com/libuv/libuv/pull/1509
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Prior to this change, several of the fs functions checked for
invalid arguments before initializing the fs request. If a
consumer received a UV_EINVAL from one of these functions, and
then called uv_fs_req_cleanup(), the application would crash, as
the pointer being freed was not allocated. This commit makes
sure that all fs functions initialize the request before returning.
Fixes: https://github.com/libuv/libuv/issues/1508
PR-URL: https://github.com/libuv/libuv/pull/1509
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
z/OS allows non root users to chown a file to root via the
CHOWN.UNRESTRICTED profile. So avoid that test on z/OS.
PR-URL: https://github.com/libuv/libuv/pull/1454
Reviewed-By: Colin Ihrig <cjihrig@gmail.com
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
File read or write from specified position will move file pointer on
Windows but not on POSIX. This makes Windows behave as other
supported platforms.
Ref: https://github.com/nodejs/node/issues/9671
PR-URL: https://github.com/libuv/libuv/pull/1357
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
The uv__get_osfhandle() function is a private functio of the
Windows subsystem, and its used to get a Windows HANDLE out
of a file descriptor number.
The motivation behind making this function public is to
allow Node.js programs to pass file descriptors created
using fs.open() to native Node.js C++ add-ons, and be able to
successfully convert them to Windows HANDLEs.
Refs: https://github.com/libuv/libuv/pull/1166
Refs: https://github.com/nodejs/node/issues/6369
Fixes: https://github.com/libuv/libuv/issues/1291
PR-URL: https://github.com/libuv/libuv/pull/1323
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Cygwin and MSYS2 are POSIX layers implemented on top of Windows.
Use our POSIX `poll(2)` implementation of our poll abstraction.
For most other components we already have dedicated sources
implementing them in terms of APIs available on Cygwin or
providing non-implementations of components not supported.
This leaves only three components that need Cygwin-specific
implementations:
* uv_uptime: implement using sysinfo
* uv_resident_set_memory: add a placeholder returning UV_ENOSYS
* uv_cpu_info: add a placeholder returning UV_ENOSYS
Update our test suite to account for features not available
due to Cygwin platform limitations or our placeholders.
PR-URL: https://github.com/libuv/libuv/pull/1312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Fixes deadstore in uv_pipe_bind as 'sockfd' is no longer used.
Fixes deadstore in test related to unused variables or missing
assert.
PR-URL: https://github.com/libuv/libuv/pull/1288
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Handle the case when it's called after the request has ended, or in case
it ended with an error.
PR-URL: https://github.com/libuv/libuv/pull/1181
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fix the #ifdef logic to make sure all the available fields filled in the
`stat` struct are correcly copied into the `uv_stat_t` struct. Before
this change, the `n_sec` were being set to 0.
PR-URL: https://github.com/libuv/libuv/pull/1152
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
In `musl` libc, defining `_GNU_SOURCE` doesn't automatically define the
other feature definitions, causing that `uv_fs_fstat` would not fill the
`nsec` fields. For the same reason, compile the tests on linux with
`-D_GNU_SOURCE` so the `fs_fstat` tests passes on `musl` platforms.
PR-URL: https://github.com/libuv/libuv/pull/1039
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
- zos: disable test cases not applicable
- zos: build options
- zos: semaphore implementation
- zos: use compare and swap builtins
- zos: struct rusage not the same as other platforms
- zos: backlog<=0 produces undefined behaviour
Will redefine backlog in the following way
* if backlog == 0, set it to 1
* if backlog < 0, set it to SOMAXCONN
- zos: define IMAXBEL as empty flag and implement uv__tty_make_raw
- zos: use udp multicast operations from aix
- zos: ESC in ebcdic
- zos: use LIBPATH for dynamic linker path
- zos: uv_udp_set_ttl only works for ipv6
- zos: increase pthread stack size by factor of 4
- zos: return ENODEV instead of ENXIO errors for setsockopt
- zos: use uv_cond_init the same way as aix
- test: enable oob test for zos
- zos: return EINVAL for zos error code EOPNOTSUPP
PR-URL: https://github.com/libuv/libuv/pull/937
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
'futimens' is only implemented on AIX 7.1. Other functions like
'utimes' and 'utimes' are merely stub functions that return ENOSYS
on AIX 6.1 and below. Skip test fs_futime for AIX versions below 7.1.
PR-URL: https://github.com/libuv/libuv/pull/811
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Equivalent to realpath(3), returns the full resolved absolute path of a
file or directory.
PR-URL: https://github.com/libuv/libuv/pull/531
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
fs_access, fs_async_dir and fs_symlink_dir could fail when the
filesystem where the tests are run does not fully support getting the
file type via getdents. Having getdents support does not imply that the
underlying filesystem fully supports what is necessary for these tests
to have passed prior to this commit. So the failing tests were updated
to check for UV_DIRENT_FILE as it did previously but it will also check for
UV_DIRENT_UNKNOWN as well to handle the filesystems that do not fully support
getting the file type via getdents. For OS X and Windows, which are
known to fully support getting the file type, the tests work as they did
before and will not check for UV_DIRENT_UNKNOWN. We could/should update the
preprocessor directive that chooses "rigorous" or "lax" checks
accordingly when we learn of new environments that should always do the
original "rigorous" checks.
Fixes: https://github.com/libuv/libuv/issues/501
PR-URL: https://github.com/libuv/libuv/pull/508
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>