Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pick a good magic/type number for ioctl?

I was wondering if there was a macro that could assign my device a random 'magic' number that linux was currently not using. This is obviously in the interest of portability. Also if this is not possible, I would like to know where I can find out which magic numbers are not used. The text file I want to consult I believe is called ioctl-number.txt, but I could only find those files in the source tree I downloaded ... not the compiled kernel that I actually run. It would be interesting to find where those files may hide in the compiled version.

Thanks for any help!

like image 595
Dr.Knowitall Avatar asked Nov 05 '22 02:11

Dr.Knowitall


1 Answers

Could you select an existing ioctl macro that your device driver does not (and will never) use, and assign its value to a macro for the ioctl you require?

I have a limited knowledge of how ioclt works with device drivers, so maybe this doesn't work.

Can you look at the source for another device driver that has custom ioctl values, and see how they've selected their numbers? Maybe there's a range that the OS doesn't use, so they're available for each device driver to interpret however it wishes.

like image 96
tomlogic Avatar answered Nov 09 '22 08:11

tomlogic