mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
deps: update to uvwasi 0.0.11
Notable changes: - Several issues have been addressed in uvwasi_fd_readdir(). A bug in the copying of the directory entry's name has been fixed. The function now returns UVWASI_ENOSYS on Windows and Android. Serdes support has been added for uvwasi_dirent_t's. - The libuv dependency has been updated to v1.39.0. PR-URL: https://github.com/nodejs/node/pull/35104 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
1 parent
992af4e112
commit
5405e62eaf
4 files changed
+39
-22
No files matched your search
Vendored
+1
-1
@@ -10,7 +10,7 @@ extern "C" {
|
||||
|
||||
#define UVWASI_VERSION_MAJOR 0
|
||||
#define UVWASI_VERSION_MINOR 0
|
||||
#define UVWASI_VERSION_PATCH 10
|
||||
#define UVWASI_VERSION_PATCH 11
|
||||
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
|
||||
(UVWASI_VERSION_MINOR << 8) | \
|
||||
(UVWASI_VERSION_PATCH))
|
||||
|
||||
Vendored
+3
@@ -103,6 +103,9 @@ IOVS_STRUCT(ciovec_t)
|
||||
#define UVWASI_SERDES_SIZE_iovec_t 8
|
||||
IOVS_STRUCT(iovec_t)
|
||||
|
||||
#define UVWASI_SERDES_SIZE_dirent_t 24
|
||||
STRUCT(dirent_t)
|
||||
|
||||
#define UVWASI_SERDES_SIZE_fdstat_t 24
|
||||
STRUCT(fdstat_t)
|
||||
|
||||
|
||||
Vendored
+28
-21
@@ -13,6 +13,10 @@
|
||||
|
||||
#define UVWASI__READDIR_NUM_ENTRIES 1
|
||||
|
||||
#if !defined(_WIN32) && !defined(__ANDROID__)
|
||||
# define UVWASI_FD_READDIR_SUPPORTED 1
|
||||
#endif
|
||||
|
||||
#include "uvwasi.h"
|
||||
#include "uvwasi_alloc.h"
|
||||
#include "uv.h"
|
||||
@@ -22,6 +26,7 @@
|
||||
#include "path_resolver.h"
|
||||
#include "poll_oneoff.h"
|
||||
#include "wasi_rights.h"
|
||||
#include "wasi_serdes.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* IBMi PASE does not support posix_fadvise() */
|
||||
@@ -1268,7 +1273,7 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
uvwasi_size_t buf_len,
|
||||
uvwasi_dircookie_t cookie,
|
||||
uvwasi_size_t* bufused) {
|
||||
/* TODO(cjihrig): Support Windows where seekdir() and telldir() are used. */
|
||||
#if defined(UVWASI_FD_READDIR_SUPPORTED)
|
||||
/* TODO(cjihrig): Avoid opening and closing the directory on each call. */
|
||||
struct uvwasi_fd_wrap_t* wrap;
|
||||
uvwasi_dirent_t dirent;
|
||||
@@ -1282,6 +1287,7 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
long tell;
|
||||
int i;
|
||||
int r;
|
||||
#endif /* defined(UVWASI_FD_READDIR_SUPPORTED) */
|
||||
|
||||
UVWASI_DEBUG("uvwasi_fd_readdir(uvwasi=%p, fd=%d, buf=%p, buf_len=%d, "
|
||||
"cookie=%"PRIu64", bufused=%p)\n",
|
||||
@@ -1295,6 +1301,7 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
if (uvwasi == NULL || buf == NULL || bufused == NULL)
|
||||
return UVWASI_EINVAL;
|
||||
|
||||
#if defined(UVWASI_FD_READDIR_SUPPORTED)
|
||||
err = uvwasi_fd_table_get(uvwasi->fds,
|
||||
fd,
|
||||
&wrap,
|
||||
@@ -1316,12 +1323,9 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
dir->nentries = UVWASI__READDIR_NUM_ENTRIES;
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
#ifndef _WIN32
|
||||
/* TODO(cjihrig): Need a Windows equivalent of this logic. */
|
||||
/* Seek to the proper location in the directory. */
|
||||
if (cookie != UVWASI_DIRCOOKIE_START)
|
||||
seekdir(dir->dir, cookie);
|
||||
#endif
|
||||
|
||||
/* Read the directory entries into the provided buffer. */
|
||||
err = UVWASI_ESUCCESS;
|
||||
@@ -1333,25 +1337,20 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
goto exit;
|
||||
}
|
||||
|
||||
available = 0;
|
||||
|
||||
for (i = 0; i < r; i++) {
|
||||
/* TODO(cjihrig): This should probably be serialized to the buffer
|
||||
consistently across platforms. In other words, d_next should always
|
||||
be 8 bytes, d_ino should always be 8 bytes, d_namlen should always be
|
||||
4 bytes, and d_type should always be 1 byte. */
|
||||
#ifndef _WIN32
|
||||
tell = telldir(dir->dir);
|
||||
if (tell < 0) {
|
||||
err = uvwasi__translate_uv_error(uv_translate_sys_error(errno));
|
||||
uv_fs_req_cleanup(&req);
|
||||
goto exit;
|
||||
}
|
||||
#else
|
||||
tell = 0; /* TODO(cjihrig): Need to support Windows. */
|
||||
#endif /* _WIN32 */
|
||||
|
||||
name_len = strlen(dirents[i].name);
|
||||
dirent.d_next = (uvwasi_dircookie_t) tell;
|
||||
/* TODO(cjihrig): Missing ino libuv (and Windows) support. fstat()? */
|
||||
/* TODO(cjihrig): libuv doesn't provide d_ino, and d_type is not
|
||||
supported on all platforms. Use stat()? */
|
||||
dirent.d_ino = 0;
|
||||
dirent.d_namlen = name_len;
|
||||
|
||||
@@ -1381,21 +1380,24 @@ uvwasi_errno_t uvwasi_fd_readdir(uvwasi_t* uvwasi,
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write dirent to the buffer. */
|
||||
available = buf_len - *bufused;
|
||||
size_to_cp = sizeof(dirent) > available ? available : sizeof(dirent);
|
||||
memcpy((char*)buf + *bufused, &dirent, size_to_cp);
|
||||
*bufused += size_to_cp;
|
||||
/* Write the entry name to the buffer. */
|
||||
/* Write dirent to the buffer if it will fit. */
|
||||
if (UVWASI_SERDES_SIZE_dirent_t + *bufused > buf_len)
|
||||
break;
|
||||
|
||||
uvwasi_serdes_write_dirent_t(buf, *bufused, &dirent);
|
||||
*bufused += UVWASI_SERDES_SIZE_dirent_t;
|
||||
available = buf_len - *bufused;
|
||||
|
||||
/* Write as much of the entry name to the buffer as possible. */
|
||||
size_to_cp = name_len > available ? available : name_len;
|
||||
memcpy((char*)buf + *bufused, &dirents[i].name, size_to_cp);
|
||||
memcpy((char*)buf + *bufused, dirents[i].name, size_to_cp);
|
||||
*bufused += size_to_cp;
|
||||
available = buf_len - *bufused;
|
||||
}
|
||||
|
||||
uv_fs_req_cleanup(&req);
|
||||
|
||||
if (*bufused >= buf_len)
|
||||
if (available == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1408,6 +1410,10 @@ exit:
|
||||
return uvwasi__translate_uv_error(r);
|
||||
|
||||
return err;
|
||||
#else
|
||||
/* TODO(cjihrig): Need a solution for Windows and Android. */
|
||||
return UVWASI_ENOSYS;
|
||||
#endif /* defined(UVWASI_FD_READDIR_SUPPORTED) */
|
||||
}
|
||||
|
||||
|
||||
@@ -2353,6 +2359,7 @@ uvwasi_errno_t uvwasi_poll_oneoff(uvwasi_t* uvwasi,
|
||||
if (err != UVWASI_ESUCCESS)
|
||||
return err;
|
||||
|
||||
timer_userdata = 0;
|
||||
has_timeout = 0;
|
||||
min_timeout = 0;
|
||||
|
||||
|
||||
Vendored
+7
@@ -84,6 +84,13 @@ uint8_t uvwasi_serdes_read_uint8_t(const void* ptr, size_t offset) {
|
||||
ALIAS(userdata_t, uint64_t) \
|
||||
ALIAS(whence_t, uint8_t) \
|
||||
\
|
||||
STRUCT(dirent_t) { \
|
||||
FIELD( 0, dircookie_t, d_next); \
|
||||
FIELD( 8, inode_t, d_ino); \
|
||||
FIELD(16, uint32_t, d_namlen); \
|
||||
FIELD(20, filetype_t, d_type); \
|
||||
} \
|
||||
\
|
||||
STRUCT(fdstat_t) { \
|
||||
FIELD( 0, filetype_t, fs_filetype); \
|
||||
FIELD( 2, fdflags_t, fs_flags); \
|
||||
|
||||
Reference in new issue
Block a user