FreeBSD 5.3-BETA6 available

Matthias Andree ma at
Tue Sep 28 08:05:15 PDT 2004

Bruce Evans <bde at> writes:

> Except EINVAL is an undocumented and unreasonable errno for write(2).
> (It is documented and reasonable for pwrite(2) because it is for
> pwrite()'s offset arg, but even for pwrite(), misaligned offsets are
> not invalid: as specified in POSIX.1 but not in pwrite(4), only
> negative args are invalid for pwrite().)

> The correct errno seems to be EIO (because the device is physically
> incapable of doing misaligned i/o).

Yes indeed, EIO is better.  It is however of paramount importance to
refuse the misaligned write operation on the raw (as in unbuffered)
device rather than round down the offset and write to the wrong offset,
as happens now in FreeBSD 4.

Imagine someone (ported Linux program) trying to write the last 64 bytes
of the MBR (IA32 or AMD64) with a new partition table at offset #448 and
the data ends up at offset #0 -> the system has just become unbootable
with trashed boot code, and the application believing everything is in

Matthias Andree

Encrypted mail welcome: my GnuPG key ID is 0x052E7D95 (PGP/MIME preferred)

More information about the freebsd-current mailing list