tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ioctl(2) numbers



    Date:        Wed, 01 Aug 2018 10:56:28 +0100
    From:        Robert Swindells <rjs%fdy2.co.uk@localhost>
    Message-ID:  <x7sh3y2ywj.fsf%ren.fdy2.co.uk@localhost>

  | Does it matter if ioctl(2) numbers overlap so long as they are in
  | different groups ?

To expand on thorpej's answer ... an "ioctl nulmber" is a 32 bit
constant which we typically build from a character (8 bits) an
integer (8 bits) and an argument size (13 bits), with 3 more bits
of no-copy, copy-in, copy-out.

If the 32 bit result is different from all others, all is fine. 

Generally, as long as it is unique amongst potentially conflicting other
ioctls (ones which might be seen in the same code path) there will not
generally be a problem ... that is a private ioctl for a disk driver could be
the same as one for an interface driver, or one used for networking (routing
tabes, or whatever) and it is unlikely anyone would ever notice, with the
possible exception of kdump, though it is not good.

In the example you gave there would be two ioctls using 10 (there are actually
lots more than that) as the command number, but with different command
groups (the 'r'/'s'), different data sizes, and different copy in/out bits.   
They are about as different as it is possible to be.

Do, however,  be consistent with the use of whits space with other nearby
lines (if all the others are "#define\t" then you should do that too.

kre



Home | Main Index | Thread Index | Old Index