Page MenuHomeFreeBSD

Fix handling of terminal sparse output block
ClosedPublic

Authored by thomas on Feb 10 2016, 10:23 PM.
Tags
None
Referenced Files
F82178537: D5248.id.diff
Fri, Apr 26, 5:27 AM
F82178163: D5248.diff
Fri, Apr 26, 5:19 AM
Unknown Object (File)
Mar 19 2024, 3:29 PM
Unknown Object (File)
Mar 19 2024, 3:03 PM
Unknown Object (File)
Dec 20 2023, 1:37 AM
Unknown Object (File)
Nov 15 2023, 2:54 AM
Unknown Object (File)
Nov 12 2023, 2:25 AM
Unknown Object (File)
Nov 11 2023, 3:15 PM
Subscribers

Details

Summary

This change reorganizes the handling of sparse output, in the
case where the last block in a file is a block of zeroes.

The intent of the previous code in that case was to force
an explicit write, but the implementation was incorrect, and
as a result the write was never performed. This new implementation
instead uses ftruncate(2) to extend the file with a trailing hole.

PR: 189284
(original PR whose fix introduced this bug)

PR: 207092

Test Plan

New test cases added to make test, providing regression tests for
both PRs.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

thomas retitled this revision from to Fix handling of terminal sparse output block.
thomas updated this object.
thomas edited the test plan for this revision. (Show Details)
thomas added reviewers: kib, sobomax.
sobomax edited edge metadata.

Looks good to me, thanks!

bin/dd/dd.c
471 ↗(On Diff #13192)

I am not a style(9) expert, but I think you might need to put blank "/*" and start comment on the next line, i.e.

/*
 * Seek past hole.  Note that we need to record the
This revision is now accepted and ready to land.Feb 10 2016, 10:35 PM
thomas edited edge metadata.

style(9) fix as noted

This revision now requires review to proceed.Feb 10 2016, 10:56 PM
sobomax edited edge metadata.
This revision is now accepted and ready to land.Feb 10 2016, 10:59 PM

Is sparse copy to the devices supposed to work ? I expect that ftruncate(2) on special nodes results in EINVAL.

thomas edited edge metadata.

Do not call ftruncate unless output is a regular file

(In the case where output is a device, ftruncate would fail,
but is useless in the first place as it won't affect its size.)

This revision now requires review to proceed.Feb 12 2016, 8:38 PM
kib edited edge metadata.
This revision is now accepted and ready to land.Feb 13 2016, 10:06 AM