From 6103d294f74b38555bea13d7652512270181fbc6 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sun, 3 Jun 2018 13:26:27 -0400 Subject: [PATCH] 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 Reviewed-By: Santiago Gimeno --- src/unix/fs.c | 8 +++++--- test/test-fs-copyfile.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/unix/fs.c b/src/unix/fs.c index de678733..66fae37e 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 6cd43b45..eadff542 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);