nodejs / nodejs/node

fs.copyFile fails if source is readonly and target is a CIFS volume

Đang mở
#60,557 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

libuv
Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.3k
Merge trung bình
4 ngày 2 giờ
Pull request đã merge (30 ngày)
283

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại điểm đầu vào copyFile của fs/promises và tái hiện lỗi trên Linux với nguồn chỉ đọc và đích CIFS có thể ghi. So sánh hành vi của Node với cp, sau đó đọc các issue Node.js và libuv được liên kết. Hoàn tất khi copyFile thành công với các quyền đã nêu mà không gặp lỗi EPERM được báo cáo.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, linux, node.js
Lĩnh vực
operating-systems
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Sôi nổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
52/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.