Skip to content

File and output stream line ending compatibility changes#3430

Open
brgoing wants to merge 2 commits into
linux-nvme:masterfrom
Micron-TPG-OSS:bgoing/o-binary-handling
Open

File and output stream line ending compatibility changes#3430
brgoing wants to merge 2 commits into
linux-nvme:masterfrom
Micron-TPG-OSS:bgoing/o-binary-handling

Conversation

@brgoing

@brgoing brgoing commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Makes Windows output behavior match other platforms by using O_BINARY to prevent text-mode line ending translation (LF to CRLF) that can corrupt binary output.

  • Introduces O_NVME_WRONLY, which includes O_BINARY when O_BINARY is defined, and updates file-open calls to use it.
  • Configures stdout and stderr to use O_BINARY on Windows

@igaw

igaw commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

I don't like this approach with overloading of the flags flags. The resulting code doesn't read well.

What about introducing something like nvme_open_binary/nvme_open_rawfile/nvme_open_datafile (or any better name) which handles this internally.

@brgoing

brgoing commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

I don't like this approach with overloading of the flags flags. The resulting code doesn't read well.

What about introducing something like nvme_open_binary/nvme_open_rawfile/nvme_open_datafile (or any better name) which handles this internally.

Okay. Thank you for the feedback. We discussed multiple approaches to this, including defining O_BINARY as 0 on Linux and including it in the flags used, introducing a new nvme_open method like you mentioned, or the modified O_WRONLY approach we went with in this PR. Each had its own drawbacks, so we figured we needed to pick one and go with it to start the conversation.

@brgoing brgoing force-pushed the bgoing/o-binary-handling branch 2 times, most recently from 2470c5b to 984ecdf Compare June 16, 2026 23:10
When opening raw data files, Windows requires the O_BINARY flag
for compatibility with behavior on other systems.  Otherwise it
translates \n line endings to \r\n.
Adds a wrapper for use when opening raw data files that adds O_BINARY
if defined.

Signed-off-by: Broc Going <bgoing@micron.com>
@brgoing brgoing force-pushed the bgoing/o-binary-handling branch from 984ecdf to a950218 Compare June 16, 2026 23:22
Sets O_BINARY for stderr and stdout for output compatibility on Windows.
Prevents Windows from converting line endings from LF to CRLF.

Signed-off-by: Broc Going <bgoing@micron.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants