sync: Reset O_NONBLOCK flag after file validation to match GNU behavior
This PR adds proper flag reset logic to the sync utility to align with GNU coreutils implementation.
Changes
- Reset
O_NONBLOCKflag before callingsyncfs()andfdatasync() - Added necessary imports:
fcntl,FcntlArg,OFlag, andAsRawFd - Applies to Linux/Android platforms only
The implementation ensures proper handling of non-blocking file descriptors before performing synchronization operations.
https://www.gnu.org/software/coreutils/manual/html_node/sync-invocation.html
GNU testsuite comparison:
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
GNU testsuite comparison:
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
Could you please add a test for this?
GNU testsuite comparison:
Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)
CodSpeed Performance Report
Merging #9437 will degrade performances by 2.34%
Comparing naoNao89:sync-remove-unwrap (3577f24) with main (415d01c)
Summary
⚡ 1 improvement
❌ 1 regression
✅ 125 untouched
⏩ 6 skipped[^skipped]
:warning: Please fix the performance issues or acknowledge them on CodSpeed.
Benchmarks breakdown
| Benchmark | BASE |
HEAD |
Change | |
|---|---|---|---|---|
| ❌ | tsort_input_parsing_heavy[5000] |
82.1 ms | 84.1 ms | -2.34% |
| ⚡ | du_max_depth_balanced_tree[(6, 4, 10)] |
33.1 ms | 32.4 ms | +2.15% |
| [^skipped]: 6 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. |
GNU testsuite comparison:
Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)
GNU testsuite comparison:
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)
GNU testsuite comparison:
Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)