Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/uu/dd/src/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,21 +743,16 @@ fn handle_o_direct_write(f: &mut File, buf: &[u8], original_error: io::Error) ->
let flags_without_direct = oflags & !OFlags::DIRECT;

// Remove O_DIRECT flag
if fcntl_setfl(&*f, flags_without_direct).is_err() {
return Err(original_error);
}
fcntl_setfl(&*f, flags_without_direct).map_err(|_| original_error)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I’m not a huge fan of this pattern, we map the error only to ignore it and return the original one.


// Retry the write without O_DIRECT
let write_result = f.write(buf);

// Restore O_DIRECT flag (GNU doesn't restore it, but we'll be safer)
// Log any restoration errors without failing the operation
if let Err(os_err) = fcntl_setfl(&*f, oflags) {
if let Err(e) = fcntl_setfl(&*f, oflags).map_err(io::Error::from) {
// Just log the error, don't fail the whole operation
show_error!(
"Failed to restore O_DIRECT flag: {}",
io::Error::from(os_err)
);
show_error!("Failed to restore O_DIRECT flag: {e}");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether we should be using show_warning here.

}

write_result
Expand Down
Loading