Portable ioctl calls

Add _IOC macros (<sys/ioccom.h>, <asm-generic/ioctl.h>) for linux and bsd's, unify ioctl() calls.
FreeBSD: use modern pts(4) interface instead of the old pty(4) one