ioctl handling fixes