unix: return UV_ENOTSUP on FICLONE_FORCE failure

Instead of returning whatever error is provided by the
underlying platform, use UV_ENOTSUP.

Fixes: https://github.com/libuv/libuv/issues/1862
PR-URL: https://github.com/libuv/libuv/pull/1863
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
This commit is contained in:
cjihrig 2018-06-03 13:26:27 -04:00
parent 0c28363059
commit 6103d294f7
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5
2 changed files with 6 additions and 4 deletions

View File

@ -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 /* 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 this is a force clone then exit. Otherwise, fall through to try using
sendfile(). */ sendfile(). */
if ((errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) || if (errno != ENOTTY && errno != EOPNOTSUPP && errno != EXDEV) {
req->flags & UV_FS_COPYFILE_FICLONE_FORCE) { err = UV__ERR(errno);
err = -errno; goto out;
} else if (req->flags & UV_FS_COPYFILE_FICLONE_FORCE) {
err = UV_ENOTSUP;
goto out; goto out;
} }
} else { } else {

View File

@ -179,7 +179,7 @@ TEST_IMPL(fs_copyfile) {
unlink(dst); unlink(dst);
r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE, r = uv_fs_copyfile(NULL, &req, fixture, dst, UV_FS_COPYFILE_FICLONE_FORCE,
NULL); 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) if (r == 0)
handle_result(&req); handle_result(&req);