【发布时间】:2018-04-20 01:15:05
【问题描述】:
我正在使用 Linux 内核中的以下系统调用,它获取进程的虚拟地址并输出以下信息:
如果此地址中的数据在内存或磁盘上。
该地址所属的页面是否被引用。
-
该地址所属的页面是否脏。
#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; }
但是,对于 ptep_t 变量和 ptep 变量,我收到以下错误。我已经研究过,这对我来说很有意义,所以我不确定问题是什么。是什么导致了错误?任何建议将不胜感激。
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
【问题讨论】:
标签: linux linux-kernel system-calls