diff --git a/src/unix/fs.c b/src/unix/fs.c index de678733a..66fae37ef 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -865,9 +865,11 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) { /* If an error occurred that the sendfile fallback also won't handle, or this is a force clone then exit. Otherwise, fall through to try using sendfile(). */ - if ((errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) || - req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { - err = -errno; + if (errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) { + err = UV__ERR(errno); + goto out; + } else if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { + err = UV_ENOTSUP; goto out; } } else { diff --git a/test/test-fs-copyfile.c b/test/test-fs-copyfile.c index 6cd43b450..eadff542b 100644 --- a/test/test-fs-copyfile.c +++ b/test/test-fs-copyfile.c @@ -179,7 +179,7 @@ TEST_IMPL(fs_copyfile) { unlink(dst); r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE, NULL); - ASSERT(r == 0 || r == UV_ENOSYS || r == UV_ENOTSUP || r == UV_ENOTTY); + ASSERT(r == 0 || r == UV_ENOSYS || r == UV_ENOTSUP); if (r == 0) handle_result(&req);