Added ioctl code from primer1 as starting point.