Skip to content

Prevent nob_copy_file from truncating its source on POSIX - #289

Open
Zaczero wants to merge 1 commit into
tsoding:next-releasefrom
Zaczero:submit/copy-alias
Open

Zaczero wants to merge 1 commit into
tsoding:next-releasefrom
Zaczero:submit/copy-alias

Conversation

@Zaczero

@Zaczero Zaczero commented Nov 22, 2026

Copy link
Copy Markdown

If src and dst are hard links to the same file, O_TRUNC empties the source before the first read, and the copy reports success. Compare the opened files’ device and inode before truncating the destination.

@Zaczero
Zaczero marked this pull request as ready for review November 22, 2026 20:07
Open the destination before comparing device and inode so hard links and symlinks are handled like identical paths. Truncate only a distinct regular file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant