MFC: fstest regression fixes - POSIX error codes.
Partial MFC of
d7c75c7a20590cab729c3d653aaa91a4960d6165:
Deal with most of the issues found by FreeBSD's fstest regression test:
* Limit path components to 255 characters. Return ENAMETOOLONG if
the limit is exceeded.
* Return EEXIST, EINVAL, and ENOTEMPTY as appropriate when the user
attempts to create, delete, or rename "." or "..", instead of EINVAL.
* Return EACCES if an attempt is made to open a file O_TRUNC without
O_RDWR or O_WRONLY, instead of silently dropping the O_TRUNC.
* Implement O_NOFOLLOW semantics generally instead of just with O_EXCL.
Not MFC'd:
* Return EISDIR if an attempt is made to open a directory for writing,
instead of EINVAL.
This is required so that /usr/bin/tar can extract to an existing
directory:
tar cf - . | (cd otherdir && tar xof -)
failed before (breaking nrelease).