fs.copyFile fails if source is readonly and target is a CIFS volume
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
Version
v22.21.1
Platform
Linux a7f6d3be6434 5.15.158-2-pve #1 SMP PVE 5.15.158-2 (2024-07-26T13:11Z) x86_64 Linux
Docker: Alpine release 3.22.2
Subsystem
fs
What steps will reproduce the bug?
Hi,
Copying sample.docx fails with EPERM because the source is read-only and the destination is a CIFS share.
Probably related to:
https://github.com/nodejs/node/issues/37284
https://github.com/libuv/libuv/issues/3117
https://github.com/nodejs/node/issues/44261
How often does it reproduce? Is there a required condition?
100% reproducible
What is the expected behavior? Why is that the expected behavior?
/mnt/smb is a CIFS-mounted volume.
sample.docx is a file with read-only permissions for the user running the below code.
Code
import {copyFile} from "fs/promises";
const src = "./sample.docx";
const dest = "/mnt/smb/sample.docx";
await copyFile(src, dest);
console.log("File copied successfully");
The fs.copyFile should be able to succeed in copying the file as long as the destination folder is writable.
What do you see instead?
Error
node:internal/modules/run_main:123
triggerUncaughtException(
^
[Error: EPERM: operation not permitted, copyfile './sample.docx' -> '/mnt/smb/sample.docx'] {
errno: -1,
code: 'EPERM',
syscall: 'copyfile',
path: './sample.docx',
dest: '/mnt/smb/sample.docx'
}
Additional information
Works with no error
cp ./sample.docx /mnt/smb/sample.docx
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Parti dal punto di ingresso copyFile di fs/promises e riproduci il malfunzionamento su Linux con un’origine in sola lettura e una destinazione CIFS scrivibile. Confronta il comportamento di Node con cp, quindi leggi le issue collegate di Node.js e libuv. Il lavoro è completo quando copyFile ha esito positivo con i permessi indicati senza l’errore EPERM segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, linux, node.js
- Ambito
- operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Attiva
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100