MFV r260710 + 275532:

Add a new method, nvlist_print_json to allow libnvpair to emit JSON.

MFC after:	1 month
Merge fixes from OpenBSD.

Check fstat return value.  Also, use off_t for file size and offsets.
Avoid iterating over end of string.

Obtained from:	OpenBSD (CVS rev. 1.41, 1.43)
MFC after:	1 week