Commit Graph
1 Commits
Author SHA1 Message Date
Cory Benfield 039d70fe60 Better handling of pipes, FIFOs, and terminals. (#3804)
Motivation:

NIOFS is able to handle a number of data types that aren't exactly
files, like pipes and FIFOs. However, its code mishandles them. These
types can read short, unlike files, and several branches in the code
don't handle that properly and end up misinterpreting the short read as
an EOF.

Along the way, there are a number of other bugs on these file types, so
we should clean all of those up as well.

Modifications:

- BufferedReader
  - Short reads no longer count as EOF.
- read() will return whatever is available, potentially returning short.
  - Non-seekable types always read sequentially.
  - Non-seekable types now `drop` properly by doing read-and-discard.
  - Non-zero initial offsets on non-seekable types are now rejected.
- BufferedWriter
  - Non-seekable files now flush sequentially.
  - Non-zero initial offsets on non-seekable types are now rejected.
- Factored out positioning logic to a FileCursor helper
- Fixed readChunks to behave better
- Fixed readToEnd to avoid over-reading.
- No longer add O_NONBLOCK to directory openFile.
- Cleaned up some docs.
- Added extensive testing of pipes and FIFOs.

Result:

Much better behaviour around pipes and FIFOs.
2026-11-26 17:33:19 +00:00