diff --git a/src/unix/fs.c b/src/unix/fs.c index cdfc9fe3..c8e9107c 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -2001,6 +2001,9 @@ int uv_fs_open(uv_loop_t* loop, PATH; req->flags = flags; req->mode = mode; + if (cb != NULL) + if (uv__iou_fs_open(loop, req)) + return 0; POST; } diff --git a/src/unix/internal.h b/src/unix/internal.h index 08d2d1ce..86e25a6b 100644 --- a/src/unix/internal.h +++ b/src/unix/internal.h @@ -334,6 +334,7 @@ int uv__random_sysctl(void* buf, size_t buflen); int uv__iou_fs_fsync_or_fdatasync(uv_loop_t* loop, uv_fs_t* req, uint32_t fsync_flags); +int uv__iou_fs_open(uv_loop_t* loop, uv_fs_t* req); int uv__iou_fs_read_or_write(uv_loop_t* loop, uv_fs_t* req, int is_read); @@ -343,6 +344,7 @@ int uv__iou_fs_statx(uv_loop_t* loop, int is_lstat); #else #define uv__iou_fs_fsync_or_fdatasync(loop, req, fsync_flags) 0 +#define uv__iou_fs_open(loop, req) 0 #define uv__iou_fs_read_or_write(loop, req, is_read) 0 #define uv__iou_fs_statx(loop, req, is_fstat, is_lstat) 0 #endif diff --git a/src/unix/linux.c b/src/unix/linux.c index 5b6613be..99ae4f17 100644 --- a/src/unix/linux.c +++ b/src/unix/linux.c @@ -146,6 +146,7 @@ enum { UV__IORING_OP_READV = 1, UV__IORING_OP_WRITEV = 2, UV__IORING_OP_FSYNC = 3, + UV__IORING_OP_OPENAT = 18, UV__IORING_OP_STATX = 21, }; @@ -208,6 +209,7 @@ struct uv__io_uring_sqe { union { uint32_t rw_flags; uint32_t fsync_flags; + uint32_t open_flags; uint32_t statx_flags; }; uint64_t user_data; @@ -673,6 +675,28 @@ int uv__iou_fs_fsync_or_fdatasync(uv_loop_t* loop, } +int uv__iou_fs_open(uv_loop_t* loop, uv_fs_t* req) { + struct uv__io_uring_sqe* sqe; + struct uv__iou* iou; + + iou = &uv__get_internal_fields(loop)->iou; + + sqe = uv__iou_get_sqe(iou, loop, req); + if (sqe == NULL) + return 0; + + sqe->addr = (uintptr_t) req->path; + sqe->fd = AT_FDCWD; + sqe->len = req->mode; + sqe->opcode = UV__IORING_OP_OPENAT; + sqe->open_flags = req->flags | O_CLOEXEC; + + uv__iou_submit(iou); + + return 1; +} + + int uv__iou_fs_read_or_write(uv_loop_t* loop, uv_fs_t* req, int is_read) { diff --git a/test/test-threadpool-cancel.c b/test/test-threadpool-cancel.c index f71cc9c3..aafa84c9 100644 --- a/test/test-threadpool-cancel.c +++ b/test/test-threadpool-cancel.c @@ -98,6 +98,7 @@ static int known_broken(uv_req_t* req) { case UV_FS_FSTAT: case UV_FS_FSYNC: case UV_FS_LSTAT: + case UV_FS_OPEN: case UV_FS_READ: case UV_FS_STAT: case UV_FS_WRITE: