を使用して usbfs デバイスをテストする必要がありioctl
ます。私は使用する必要がありますioctl(fd, USBDEVFS_REAPURBNDELAY, &receive);
。ただしUSBDEVFS_REAPURBNDELAY
、カーネルヘッダーで定義されているため、次のようなカーネルファイルを含めます。
#include <linux/usb.h>
#include <linux/usbdevice_fs.h>
#include <asm/byteorder.h>
#include <linux/usb/ch9.h>
そしてそれをコンパイルしますgcc -g -I /usr/src/linux-3.4.4-2-pae/include/ -o /home/madper/kernel/usb/select_for_usb /home/madper/kernel/usb/select_for_usb.c
と言いました#warning "Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders" [-Wcpp]
そして、多くのエラーが発生したため、カーネルヘッダーを使用する正しい方法は何ですか?
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:21:2: error: unknown type name ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:36:2: error: unknown type name ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:37:33: error: ‘kernel_ulong_t’ undeclared here (not in a function)
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:37:3: error: requested alignment is not an integer constant
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:119:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:141:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:154:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:168:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:179:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:187:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:195:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:200:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:227:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:260:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:314:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:341:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:366:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:413:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:433:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:444:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:479:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:508:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:540:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:551:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:566:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/usr/src/linux-3.4.4-2-pae/include/linux/mod_devicetable.h:582:2: error: expected specifier-qualifier-list before ‘kernel_ulong_t’
/home/madper/kernel/usb/select_for_usb.c: In function ‘main’:
/home/madper/kernel/usb/select_for_usb.c:46:30: error: expected expression before ‘void’