implement IOCTLs properly

Signed-off-by: Antti Palosaari <crope@iki.fi>