Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement an option to align final incomplete data chunk
Writing unaligned data causes `EINVAL` (from `write(2)`): > EINVAL > fd is attached to an object which is unsuitable for writing; or the > file was opened with the O_DIRECT flag, and either the address > specified in buf, the value specified in count, or the current file > offset is not suitably aligned. This pull request implements an opt-in option (to preserve backwards compatibility) called `align`, that when used in conjunction to `flush`, will cause the incomplete data chunk to be padded with null bytes to match the passed chunk size. For example, in the added test, the chunk size is 4 bytes, and we push three chunks: - `12`: 2 bytes - `34`: 2 bytes - `5`: 1 byte The final incomplete data chunk will become `5\0\0\0` (to match the specified 4 bytes) if the `align` option was enabled. Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
- Loading branch information
Showing
3 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters