Repository navigation
Bun.write: fall back to read/write when copy_file_range fails with EBADF on an O_APPEND destination - #46636
Bun.write: fall back to read/write when copy_file_range fails with EBADF on an O_APPEND destination#46636back2dos wants to merge 1 commit into
Conversation
…ADF on an O_APPEND destination copy_file_range(2) returns EBADF for an O_APPEND destination; only EINVAL was handled. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughOn Linux and Android, ChangesAppend-mode file copy
Suggested reviewers: Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
Thank you for this change. #41685 is an older pull request for the same |
What does this PR do?
Bun.write(Bun.stdout, Bun.file(path))goes throughcopy_file_range(2)on Linux. That call fails withEBADFwhen the destination was opened withO_APPEND, which is what>>does to stdout.do_copy_file_rangeonly handledEINVAL(and clearsO_APPENDthere), so the write rejected:When the first call fails with
EBADF, this now falls back to the read/write loop, which appends as expected, and a destination that really is a bad fd still fails there with its own error.How did you verify your code works?
test/js/bun/io/bun-write.test.jsthat runs the command above with>>and checks the output and the file.EBADFerror.bun bd teston this change, and the Rust is uncompiled.🤖 Generated with Claude Code