HomeFreeBSD

write.2: Add EINVAL to ERRORS

Description

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

(cherry picked from commit bd173a540c0ead4881b0866b721955440e3b96fe)

Details

Provenance
felix.the.red_gmail.comAuthored on Jul 3 2025, 8:27 PM
ziaeeCommitted on Jul 14 2025, 5:23 PM
Reviewer
imp
Differential Revision
D51138: Mention write(2) can return EINVAL in when the target is a block device
Parents
rG0410aae4f8db: pf.4: Add pf_enable to SYNOPSIS
Branches
Unknown
Tags
Unknown