Commit Graph

116 Commits

Author SHA1 Message Date
Bartosz Sosnowski
0bd8f5bf36 win: restore file pos after positional read/write
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>
2017-06-21 12:47:00 +02:00
Juan Cruz Viotti
e133923e93 win: make uv__get_osfhandle() public
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>
2017-05-30 11:53:31 -04:00
Brad King
6398251aff cygwin: implement support for cygwin and msys2
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>
2017-05-21 16:12:21 +02:00
Rasmus Christian Pedersen
cd676e2dbc unix,test: deadstore fixes
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>
2017-04-05 09:57:20 -04:00
muflub
c8ab24bb92 fs: fix crash in uv_fs_scandir_next
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>
2017-01-17 21:15:43 -06:00
Santiago Gimeno
c02176a230
fs: fix uv__to_stat on BSD platforms
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>
2016-12-06 12:08:18 +01:00
Will Speak
cded27b663 test: fix sign-compare warning
PR-URL: https://github.com/libuv/libuv/pull/1089
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-10-19 11:57:59 -04:00
Vit Gottwald
fa81a1b2d7 test: fix fs_fstat on Android
Fixes: https://github.com/libuv/libuv/issues/1051
PR-URL: https://github.com/libuv/libuv/pull/1056
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2016-09-19 11:14:28 +01:00
Santiago Gimeno
0d7f72f219 fs: fix uv_fs_fstat on platforms using musl libc
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>
2016-09-10 10:28:14 +02:00
John Barboza
1cff5b7557 zos: add support for new platform
- 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>
2016-08-19 01:34:29 +02:00
Jason Ginchereau
399e2c8140 win: support sub-second precision in uv_fs_futimes()
Fixes: https://github.com/libuv/libuv/issues/800
PR-URL: https://github.com/libuv/libuv/pull/849
Reviewed-by: Bert Belder <bertbelder@gmail.com>
2016-05-29 11:58:46 +02:00
Imran Iqbal
4aeed1ac13 unix: implement uv__fs_futime for AIX 7.1
'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>
2016-04-08 21:08:13 +02:00
Yuval Brik
e76b8838e5 fs: add uv_fs_realpath()
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>
2015-12-05 11:32:58 +01:00
Jeremy Whitlock
30fc362560 tests: fix fs tests run w/o full getdents support
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>
2015-09-03 23:47:54 +02:00
Ben Noordhuis
df62b54aa2 unix,windows: allow NULL loop for sync fs requests
Synchronous file operations don't need an event loop.  Permit NULL as
the event loop parameter.

Fixes: https://github.com/libuv/libuv/issues/469
PR-URL: https://github.com/libuv/libuv/pull/479
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-18 15:39:21 +02:00
Karl Skomski
939ea06f45 unix,win: return EINVAL on nullptr args in uv_fs_{read,write}
PR-URL: https://github.com/libuv/libuv/pull/470
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-11 13:35:54 +02:00
ronkorving
2bf782777f unix: allow nbufs > IOV_MAX in uv_fs_{read,write}
This allows writing and reading any amount of buffers,
regardless of what IOV_MAX may be defined as.

It also moves the IOV_MAX test from stream to core.

This is based on the excellent work of @bwijen in #269.

Refs: https://github.com/libuv/libuv/pull/269
PR-URL: https://github.com/libuv/libuv/pull/448
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-08-04 11:31:04 +02:00
João Reis
0db81a98ff win: fix unlink of readonly files
Unix unlinks files even if they are not writable, windows version should behave similarly.

Fixes: https://github.com/joyent/node/issues/3006
PR-URL: https://github.com/libuv/libuv/pull/327
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-05-01 01:18:57 +02:00
Saúl Ibarra Corretgé
7dcc3e0cf0 win: fix uv_fs_access on directories
For posterity, these are the rules for access on Windows (taken from
CPython's implementation), Access is possible if:

* Write access wasn't requested
* The file isn't read-only
* It's a directory (directories cannot be read-only on Windows)

PR-URL: https://github.com/libuv/libuv/pull/316
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-04-13 10:22:18 +02:00
Massimiliano Torromeo
fd3cf20a37 unix: fix glibc-2.20+ macro incompatibility
Since glibc-2.20 the _SVID_SOURCE macro is deprecated and the newer
_DEFAULT_SOURCE macro should be used instead.

Fixes: https://github.com/libuv/libuv/issues/173
PR-URL: https://github.com/libuv/libuv/pull/213
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2015-02-26 21:08:07 +01:00
Saúl Ibarra Corretgé
3ddfb4a9cc windows: fix setting dirent types on uv_fs_scandir_next
Also make the tests more strict.

PR-URL: https://github.com/libuv/libuv/pull/201
Reviewed-By: Tim Caswell <tim@creationix.com>
Reviewed-By: Bert Belder <bertbelder@gmail.com>
2015-02-12 09:05:48 +01:00
Bert Belder
cb2f6a9743 test: fix test-fs-file-loop on Windows
* Check whether uv_fs_symlink() succeeds.
* Bail out early if we're on an old version of windows, or if we're not
  able to create symlinks because we're not elevated.

PR-URL: https://github.com/libuv/libuv/pull/55
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
2014-12-11 17:02:26 +01:00
Unknown W. Brackets
5ac921bb6a windows: fix fs_read with nbufs > 1 and offset
ReadFile() does not seem to update the offset at all.
2014-10-26 07:49:00 -03:00
Unknown W. Brackets
6760d51b52 windows: fix fs_write with nbufs > 1 and offset
When multiple bufs are specified, overlapped needs to be advanced
manually between each write.  Without this, each buf will be written
to the same position (if offset is specified.)

ReadFile() automatically advances, but WriteFile() does not.
2014-10-20 22:44:46 +02:00
cjihrig
c18205a1c5 unix, windows: add uv_fs_access() 2014-10-13 10:23:53 +02:00
Saúl Ibarra Corretgé
03e53f1cf7 fs: rename uv_fs_readdir to uv_fs_scandir
Closes #1431
2014-09-25 10:09:58 +02:00
Fedor Indutny
2f54947b72 fs: fix readdir on empty directory
`uv_fd_readdir()` should initialize all fields even if there are no
files. Fix the implementation and fix the test that should have been
covered it.
2014-09-23 21:06:54 +04:00
Saúl Ibarra Corretgé
df8ab507a0 fs: extend reported types in uv_fs_readdir_next
Support all possible types on Unix, and files, directories and links on
Windows. Some systems (hello SunOS!) don't have the d_type field on struct
dirent, so mark them as UV_DIRENT_UNKNOWN.
2014-08-15 16:44:44 +02:00
Fedor Indutny
ab2c4425a5 fs: introduce uv_readdir_next() and report types
Introduce:

    int uv_fs_readdir_next(uv_fs_t* req, uv_dirent_t* ent);

`uv_fs_readdir()` is not returning a file names list in `req->ptr`
anymore, the proper way to gather them is to call `uv_fs_readdir_next()`
in a callback.
2014-08-14 17:19:45 +04:00
Pavel Platto
e99b89f2ad unix, windows: add uv_fs_mkdtemp 2014-07-31 09:43:55 +02:00
Andrew Low
cdc979dbe0 aix: improve AIX compatibility 2014-07-22 22:57:24 +02:00
Saúl Ibarra Corretgé
218f48ae56 build: fix compilation warning on MinGW-w64 2014-06-19 23:25:43 +02:00
Saúl Ibarra Corretgé
422d2810b3 unix, windows: make uv_cwd be consistent with uv_exepath
Fixes #446
2014-02-27 09:44:28 +01:00
Saúl Ibarra Corretgé
3a8767e35e unix: fix uv_fs_write when using an empty buffer 2014-02-26 23:59:29 +01:00
Benjamin Saunders
13dd3502a7 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-23 17:24:05 +01:00
Fedor Indutny
a03ea239db Revert "fs: vectored IO API for filesystem read/write"
This reverts commit 7df24583e5.
2014-02-18 21:48:13 +04:00
Benjamin Saunders
7df24583e5 fs: vectored IO API for filesystem read/write
This improves API consistency with uv_read and uv_write and may
improve efficiency for some uses. Vectored IO is emulated when the
requisite system calls are unavailable.
2014-02-18 12:30:20 +04:00
Ben Noordhuis
f5baf210df test: wrap long lines at 80 columns 2013-09-11 17:29:43 +02:00
Ben Noordhuis
4ce3a312aa test: fix signed/unsigned comparison warnings 2013-07-25 11:25:53 +02:00
Ben Noordhuis
3ee4d3f183 unix, windows: return error codes directly
This commit changes the libuv API to return error codes directly rather
than storing them in a loop-global field.

A code snippet like this one:

    if (uv_foo(loop) < 0) {
      uv_err_t err = uv_last_error(loop);
      fprintf(stderr, "%s\n", uv_strerror(err));
    }

Should be rewritten like this:

    int err = uv_foo(loop);
    if (err < 0)
      fprintf(stderr, "%s\n", uv_strerror(err));

The rationale for this change is that it should make creating bindings
for other languages a lot easier: dealing with struct return values is
painful with most FFIs and often downright buggy.
2013-07-07 09:51:00 +02:00
Ben Noordhuis
d0be852cb1 test: fix fs_chown when running as root
chown(2) to root is expected to fail - unless you're root, of course.
2013-07-02 13:39:28 +02:00
Ben Noordhuis
d4f6165346 test: fix fs_fstat test on sunos
The tests are no longer compiled with -D_XOPEN_SOURCE=500 when building
with autotools. Tell the test explicitly that SunOS systems are
expected to have nanosecond fstat(2) granularity.
2013-07-02 13:34:19 +02:00
Saúl Ibarra Corretgé
f9e6029b82 unix, windows: add extra fields to uv_stat_t 2013-06-28 00:42:37 +02:00
Ben Noordhuis
ede83188f3 test: don't use S_IREAD and S_IWRITE
They're BSD-isms and obsolete ones at that. Replace with S_IRUSR and
S_IWUSR. Alias as _S_IREAD and _S_IWRITE on Windows because the '90s
never ended in Redmond, WA.
2013-05-31 12:50:19 +02:00
Timothy J Fontaine
499c7976c6 unix, windows: nanosecond resolution for uv_fs_[fl]stat
Closes #739.
2013-03-19 21:48:15 +01:00
Ben Noordhuis
da71649991 unix, windows: make uv_fs_t.statbuf public
Make the statbuf field public. This means you no longer have to use
req->ptr - though that still works and will continue to work for the
foreseeable future.

Fixes #704.
2013-02-10 17:50:03 +01:00
Ben Noordhuis
4ba03ddd56 unix, windows: rename uv_run2 to uv_run
This changes the prototype of uv_run() from:

  int uv_run(uv_loop_t* loop);

To:

  int uv_run(uv_loop_t* loop, uv_run_mode mode);

Where `mode` is UV_RUN_DEFAULT, UV_RUN_ONCE or UV_RUN_NOWAIT.

Fixes #683.
2013-01-16 23:35:29 +01:00
Ben Noordhuis
847182cdf1 test, bench: make functions/variables static
Make functions and variables that are local to the compilation unit
static. Remove what turns out to be unused.
2013-01-06 22:31:48 +01:00
Bert Belder
47eb03490a test: move loop cleanup code to the individual tests 2012-10-17 01:24:49 +02:00
Ben Noordhuis
e474a2a420 test: fix memory leak in test-fs.c 2012-10-02 23:10:59 +02:00