Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common/file: Fix handling of non-regular files in file_copy #523

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

MPeisl
Copy link
Member

@MPeisl MPeisl commented Feb 21, 2025

In file_copy, the input file size got calculated using the min of fstat(2) and the provided countbs. For non-regular files like /dev/zero this lead to wrong behaviour as fstat reports 0 for such files. Now, for positive counts always countbs is taken as input file size. In case a write operation returns 0 it is assumed that no input data is left for copying.

@MPeisl MPeisl requested review from quitschbo and k0ch4lo February 21, 2025 10:45
@MPeisl MPeisl force-pushed the feature/sendfile branch 7 times, most recently from f5df6ff to fc7c7f0 Compare February 24, 2025 13:27
In file_copy, the input file size got calculated  using the min of fstat(2)
and the provided count*bs. For non-regular files like /dev/zero this
lead to wrong behaviour as fstat reports 0 for such files.
Now, for positive counts always count*bs is taken as input file size. In
case a write operation returns 0 it is assumed that no input data is left for
copying.

Signed-off-by: Maximilian Peisl <[email protected]>
@quitschbo quitschbo merged commit c40ffcf into gyroidos:main Feb 24, 2025
2 checks passed
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.

2 participants