Reputation: 33
I'm working with the following system call in the Linux kernel that takes a virtual address of a process and outputs the following information:
If the data in this address is in memory or on disk.
If the page which this address belongs to has been referenced or not.
If the page which this address belongs to is dirty or not.
#include<linux/kernel.h>
#include<linux/sched.h>
#include<asm/page.h>
#include<asm/pgtable.h>
#include<linux/mm_types.h>
asmlinkage int sys_vma_props(unsigned long mem,int pid)
{
struct task_struct *task=find_task_by_vpid(pid);
struct mm_struct *memory=task->active_mm;
int data=0;
int ref=0;
int dirty =0;
pgd_t *pgd=pgd_offset(memory,mem);
pud_t *pud=pud_offset(pgd,mem);
pmd_t *pmd=pmd_offset(pud,mem);
ptet_t *ptep=pte_offset_kernel(pmd,mem);
pte_t pte=*ptep;
data=pte_present(pte);
printk("present flag: %i\n",data?1:0);
ref=pte_young(pte);
printk("referenced flag: %i\n",ref?1:0);
dirty=pte_dirty(pte);
printk("dirty flag: %i\n",dirty?1:0);
return 0;
}
However, I'm getting the following error for the ptep_t variable and the ptep variable. I've researched and this makes sense to me so I'm not really sure what the problem is. What's causing the error? Any advice would be much appreciated.
address/sys_vadd.c:19: error: ‘ptep_t’ undeclared (first use in this function)
address/sys_vadd.c:19: error: (Each undeclared identifier is reported only once
address/sys_vadd.c:19: error: for each function it appears in.)
address/sys_vadd.c:19: error: ‘ptep’ undeclared (first use in this function)
address/sys_vadd.c:20: warning: ISO C90 forbids mixed declarations and code
Upvotes: 1
Views: 232
Reputation: 26355
The problem is that you've used the wrong type for the ptep
variable. It should be pte_t
not ptet_t
.
Upvotes: 1