Allow specifying R/W flags for reads and writes on tokio_uring::fs::File
#326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello everyone! I propose adding methods to
tokio_uring::fs::File
that would allow passingRWF_
flags to read and write operations.Explanation
Along with ordinary I/O system calls (
read()
/write()
), vectored I/O (readv()
/writev()
), positional I/O (pread()
/pwrite()
) and vectored positional I/O (preadv()
/pwritev()
), Linux also has file I/O system callspreadv2()
andpwritev2()
that, in addition topreadv()
/pwritev()
, allow passing read/write flags, that affect individual I/O operations. Examples of such flags areRWF_NOWAIT
(for reading, which means if it has to perform some possibly-blocking operations, it instead should fail withEAGAIN
) andRWF_APPEND
(perform an atomic append even if the file is opened withoutO_APPEND
flag). io_uring also allows passing these flags in submissions.Possible benefits
This would be useful for implementing writing to stdout and stderr using io_uring. Stdout and/or stderr may point to regular files, but don't have the
O_APPEND
flag set, which means, if several processes have their stdout or stderr redirected to such file, they would have to specifyRWF_APPEND
when writing to such file to avoid overwriting each other's data.