From 2681bf09c51bbd82604a3c7a3e09246cfcd6f7ea Mon Sep 17 00:00:00 2001 From: skooch Date: Wed, 11 Mar 2026 14:44:36 +1100 Subject: [PATCH] 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 --- src/unix/fs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/unix/fs.c b/src/unix/fs.c index a45c95a17..4a9e8d9a1 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -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__ */ } /*