git: bd173a540c0e - main - write.2: Add EINVAL to ERRORS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 04 Jul 2025 05:15:22 UTC
The branch main has been updated by ziaee:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd173a540c0ead4881b0866b721955440e3b96fe
commit bd173a540c0ead4881b0866b721955440e3b96fe
Author: Felix Johnson <felix.the.red@gmail.com>
AuthorDate: 2025-07-03 20:27:22 +0000
Commit: Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2025-07-04 05:14:19 +0000
write.2: Add EINVAL to ERRORS
Since phk rewrote the block layer ~2 decades ago, write(2) can return
EINVAL when the target is a block device and nbytes, the write size, is
not a multiple of the sector's block size.
From the original PR:
When coming from Linux, people are surprised by the fact
that write(2) to a device must be aligned to block size.
Writing a non-aligned block onto a raw device is a case
where EINVAL is also returned but the manpage does not mention this.
MFC after: 3 days
PR: 227185
Reported by: riggs
Reviewed by: imp, Pau Amma <pauamma@gundo.com>
Differential Revision: https://reviews.freebsd.org/D51138
---
lib/libsys/write.2 | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/libsys/write.2 b/lib/libsys/write.2
index 7ff1c42715d6..d2ff41ceead9 100644
--- a/lib/libsys/write.2
+++ b/lib/libsys/write.2
@@ -195,6 +195,9 @@ is greater than
if the sysctl
.Va debug.iosize_max_clamp
is non-zero).
+.It Bq Er EINVAL
+The file descriptor refers to a raw device, and the write
+offset or size is not a multiple of the device's block size.
.It Bq Er EINTEGRITY
The backing store for
.Fa fd