coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

sync: Reset O_NONBLOCK flag after file validation to match GNU behavior

Open naoNao89 opened this issue 1 month ago • 8 comments

This PR adds proper flag reset logic to the sync utility to align with GNU coreutils implementation.

Changes

  • Reset O_NONBLOCK flag before calling syncfs() and fdatasync()
  • Added necessary imports: fcntl, FcntlArg, OFlag, and AsRawFd
  • 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

naoNao89 avatar Nov 21 '25 14:11 naoNao89

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 21 '25 14:11 github-actions[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 21 '25 19:11 github-actions[bot]

Could you please add a test for this?

sylvestre avatar Nov 28 '25 12:11 sylvestre

GNU testsuite comparison:

Skip an intermittent issue tests/misc/tee (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Nov 28 '25 22:11 github-actions[bot]

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.

codspeed-hq[bot] avatar Dec 09 '25 19:12 codspeed-hq[bot]

GNU testsuite comparison:

Skip an intermittent issue tests/tail/overlay-headers (fails in this run but passes in the 'main' branch)

github-actions[bot] avatar Dec 09 '25 19:12 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Dec 10 '25 18:12 github-actions[bot]

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/overlay-headers (passes in this run but fails in the 'main' branch)

github-actions[bot] avatar Dec 10 '25 20:12 github-actions[bot]