Hi,
I am learning the internals of the FreeBSD kernel. I wrote a simple kernel module which is supposed to list all the process IDs, while loading the module, by traversing the process list. Below is the relevant part of the code:
Note: curr is defined as struct proc.
Now when I load this kernel module using
I am learning the internals of the FreeBSD kernel. I wrote a simple kernel module which is supposed to list all the process IDs, while loading the module, by traversing the process list. Below is the relevant part of the code:
Code:
case MOD_LOAD:
curr = curproc->p_list.le_next;
while(curr->p_pid != curproc->p_pid) {
uprintf("%d\n",curr->p_pid);
curr = curr->p_list.le_next;
}
Note: curr is defined as struct proc.
Now when I load this kernel module using
kldload, I get a page fault error after some PIDs are listed and the system reboots. My understanding of this issue is that some processes are not in memory and when I tries to access it, I get the page fault. So my question is how can I ensure that relevant data structure is loaded to the memory before accessing it in the FreeBSD kernel?