FreeBSD: fix compiler warnings

mode_t is u_int16_t on FreeBSD and u_int32_t on other platforms.
Silenced the compiler by casting but maybe a union should be used here
instead.