It might be a incoherent question about kernel headers as I don't have clear understanding about it and where and how it is used. I think it might get flagged down. My question has 3 parts:
I think Kernel headers provide a interface so that other part of the kernel, like modules, can use them. That's my bookish knowledge. I haven't seen or found any code that used kernel headers (I would appreciate if someone can point me to it). Can it be used in userspace too? Any code example would be appreciated.
I found out that using
make headers_installkernel headers are exposed for by userspace, but at the same time it is discouraged to use kernel headers in userspace. If it is discouraged then what is the use of exposing it to userspace?As per this and this, kernel header files (.h files) should be at 3 places: a.
/usr/include/linux/kernel.hwhich is intended for user space b./lib/modules/$(uname -r)/build/include/linux/sched.hwhich is external modules c./usr/src/...which is used for kernel modules Does it mean header files in different directories have different purpose or different interface or signature? In other words, does#include <linux/xyz.h>in a userspace code has different meaning than#include <linux/xyz.h>in kernel module? Also is external module same as kernel module?
Thanks.