ioctlコマンドをデコードする方法を理解するには、適切なドキュメントを参照するように注意してください。新しいDocumentation/ioctl-number.txt
ioctlコードを作成する方法を説明しますが、前の回答でリンクされているドキュメントは、ioctlの作成にも焦点を当てる前のプロセス全体の概要を示しています。ioctlの実際のマスキングはアーキテクチャによって異なる可能性があるため、より適切なソースですが、一般的な規則とビットフィールドの意味と位置の説明は、とにあります。asm/ioctl.h
include/asm-generic/ioctl.h
Documentation/ioctl-decoding.txt
後者から:
bits meaning
31-30 00 - no parameters: uses _IO macro
10 - read: _IOR
01 - write: _IOW
11 - read/write: _IOWR
29-16 size of arguments
15-8 ascii character supposedly
unique to each driver
7-0 function #
上記によると、cmd = 3222823425は次のようにデコードする必要があります:
3222823425-> 0xC0186201-> 11000000000110000110001000000001
- `direction` -> `11` -> read/write;
- `size` -> `00000000011000` -> 24 bytes (a pointer to a struct of
this size should be passed as 3rd
argument of ioctl();
- `type` -> `01100010` -> 0x62, ascii for character 'b';
- `number` -> `00000001` -> driver function #1.
これがお役に立てば幸いです。よろしく。