in reply to Inappropriate ioctl for device

Under what circumstances does your code work? When doesn't it work? What does your code look like?