프로세스 ID가 이미 알고있는 사용자 프로세스의 task_struct에 액세스 할 수있는 커널 모듈을 구현하려고합니다. 나는 커널에 삽입하려고 할 때 그것을주고, 그것은 내가 * .ko 파일을 얻고 성공적으로 컴파일지고insmod : 커널 모듈을 삽입 할 때 오류가 발생했습니다.
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/pid.h>
#include <linux/pid_namespace.h>
int init_module(void)
{
//Declaring the variables
int p_id = 6980; //6980 is the process ID of my user process
struct pid *pid_struct;
struct task_struct *task;
// Trying to access the variables of the p_id
pid_struct = find_get_pid(p_id);
task = pid_task(pid_struct, PIDTYPE_PID);
//Printing the info from the task_struct
printk(KERN_INFO "*** [%d]\n",task->pid);
return 0;
}
void cleanup_module(void)
{
return;
}
:하지만, 나는 프로세스의 task_struct에를 얻을 수 find_get_pid
및 pid_task
을 사용하고 있습니다 나 오류 : dmesg를 나에게 다음과 같은 출력을주고있다
insmod: error inserting 'main.ko': -1 Unknown symbol in module
: 누군가가 나를 도울 수 있다면 내가 진행하는 방법을 잘 모릅니다
main: Unknown symbol find_get_pid (err 0)
, 그것은 정말 감사하겠습니다.
예, 이것이 원인 일 수 있습니다. [find_get_pid()] (http://lxr.free-electrons.com/ident?i=find_get_pid)는 실제로 GPL로만 내보내집니다. – Eugene
고마워요. 문제가 해결되었습니다. – vidzi