Skip to content

Commit 2f65b5f

Browse files
committed
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: nodejs/node#56248 Refs: #4396
1 parent a19ceeb commit 2f65b5f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/unix/fs.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,20 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
13261326

13271327
if (futimens(dstfd, times) == -1) {
13281328
err = UV__ERR(errno);
1329+
#ifdef __linux__
1330+
/* futimens() on CIFS/SMB shares may fail with EPERM. Since preserving
1331+
* timestamps is best-effort, detect that condition and squelch the error.
1332+
*/
1333+
if (err != UV_EPERM)
1334+
goto out;
1335+
1336+
if (!uv__is_cifs_or_smb(dstfd))
1337+
goto out;
1338+
1339+
err = 0;
1340+
#else /* !__linux__ */
13291341
goto out;
1342+
#endif /* !__linux__ */
13301343
}
13311344

13321345
/*

0 commit comments

Comments
 (0)