すべてのシステムコールの定数を取得しようとしていますが、 と の間でカーネルのソースに大きな混乱があるinclude/asm/unistd.h
ようinclude/asm/unistd_XX.h
ですinclude/asm-generic/unistd.h
。
それらのそれぞれの違いは何ですか?
取得したい場合は、どちらを使用する必要がありますか:
a) x86 syscalls
b) x64 syscalls
c) IA32 emulation syscalls
したがって、正しい方法はunistd.h
for x64
and/or unistd_32.h
for x86
andを使用することia32
です。これらのファイルは、Linux ディストリビューションのヘッダーにあります。ただし、パスはディストリビューション間で (さらにはカーネル間でも) 変わることに注意してください。そのため、これらのファイルが正確にどこにあるかを確認する最良の方法は次のとおりです。
uni_hack.h
#if defined(CONFIG_X86) <---- replace with whatever you want, #ifdef CONFIG_IA32_EMULATION for example
# include <asm/unistd_32.h>
#endif
-
Kbuild file
obj-m += kernel_module_example.o
$(obj)/kernel_module_example.o: $(obj)/real_unistd.h
$(obj)/real_unistd.h: $(src)/uni_hack.h FORCE
cpp $(c_flags) -E -dM <$< >$@ <---- this will generate "real_unistd.h" in the directory of your kernel module, and it will contain the content of unistd_32.h
unistd.h
forの使用は、ソース コードで -ing するx64
だけの問題です。#include