brian nyaberi
brian nyaberi

Reputation: 33

Undeclared ptep_t in linux_kernel system call

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:

  1. If the data in this address is in memory or on disk.

  2. If the page which this address belongs to has been referenced or not.

  3. 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

Answers (1)

user1118321
user1118321

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

Related Questions