Repository navigation
sync: fsync() file operands when no -d/-f flags (GNU MODE_FILE compat) - #14592
lostallmymoney wants to merge 2 commits into
Conversation
|
GNU testsuite comparison: |
bb3bc91 to
466fb2b
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||
| fdatasync(&files)?; | ||
| } else if !files.is_empty() { | ||
| #[cfg(any(target_os = "linux", target_os = "android"))] |
There was a problem hiding this comment.
We probably should keep sync fallback on other targets.
There was a problem hiding this comment.
We could remove this cfg using std::fs::File::sync_data instead of rustix. I'm working on it at #15733 .
|
the CI has been failing on this one for a while, could you please have a look? otherwise, i will close it, thanks |
Hey pardon me, I am out of my universe here. I know the fix isn't big and is for a missing feature (file sync which started doing global syncs since rust utils, one error on drive B prevented initramfs generation from syncing on drive A). oech3's comment intrigues me and I do not know the specifics of the targets, I wouldn't want to dirty it up. The test tries to sync and unsync'able file, and fails, which is the way we know it doesn't try to sync the full drive instead. It shouldn't be necessary but would be an indicator of the feature loss coming back. I do not know what environment the test runs on, and if this test is dependant on the environment then I'm not even sure it should be there or under that shape. Thanks ! |
| fn test_sync_file_operands_fsync_each_file() { | ||
| // Regression test: `sync FILE` (no -d/-f flags) must fsync each file | ||
| // like GNU coreutils, not fall back to a global sync() that ignores | ||
| // the operands. /proc/self/mem rejects fsync() with EINVAL, so this |
There was a problem hiding this comment.
| // the operands. /proc/self/mem rejects fsync() with EINVAL, so this | |
| // the operands. /dev/null rejects fsync() with EINVAL, so this |
With file operands and no --data/-d or --file-system/-f flag, GNU sync enters MODE_FILE and fsync()s each operand. uutils instead falls through to a global sync(), silently ignoring the operands and blocking on every filesystem behind initramfs/dracut. Add an fsync(2) path (Linux/Android) mirroring do_fdatasync, and a regression test using /proc/self/mem which rejects fsync() with EINVAL (a global sync() would wrongly exit 0). Fixes: uutils#14591
Co-authored-by: oech3 <79379754+oech3@users.noreply.github.com>
a533597 to
e8d02e5
Compare
With file operands and no --data/-d or --file-system/-f flag, GNU sync enters MODE_FILE and fsync()s each operand. uutils instead falls through to a global sync(), silently ignoring the operands and blocking on every filesystem behind initramfs/dracut. Add an fsync(2) path (Linux/Android) mirroring do_fdatasync, and a regression test using /proc/self/mem which rejects fsync() with EINVAL (a global sync() would wrongly exit 0).
Fixes: #14591