Support freebsd

The only real ugliness here is ENODATA, which doesn't exist on freebsd.