unix: squelch futimens() EPERM on CIFS/SMB shares in copyfile

futimens() on CIFS/SMB shares may fail with EPERM because these
filesystems do not support setting arbitrary timestamps. Since
preserving timestamps during copyfile is best-effort, detect the
CIFS/SMB condition using uv__is_cifs_or_smb() and squelch the error,
matching the existing handling for fchmod() in the same function.

Without this fix, uv_fs_copyfile() fails with EPERM when copying
files to CIFS/SMB mounts on Linux (e.g. Alpine containers with
mounted cifs shares).

Fixes: https://github.com/nodejs/node/issues/56248
Refs: https://github.com/libuv/libuv/pull/4396
This commit is contained in:
skooch 2026-03-11 14:44:36 +11:00 committed by Saúl Ibarra Corretgé
parent d2a45ce364
commit 2681bf09c5

View File

@ -1327,7 +1327,17 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
if (futimens(dstfd, times) == -1) {
err = UV__ERR(errno);
#ifdef __linux__
/* futimens() on CIFS/SMB shares may fail with EPERM. Since preserving
* timestamps is best-effort, detect that condition and squelch the error.
*/
if (err == UV_EPERM && uv__is_cifs_or_smb(dstfd))
err = 0;
else
goto out;
#else /* !__linux__ */
goto out;
#endif /* !__linux__ */
}
/*