some bug fixing around ioctls