LInux内核API查找与虚拟地址相对应的vma [英] LInux Kernel API to find the vma corresponds to a virtual address
本文介绍了LInux内核API查找与虚拟地址相对应的vma的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何内核API可以找到与虚拟地址相对应的VMA?
Is there any Kernel API to find the VMA corresponds to virtual address?
示例:如果一个地址为0x13000,我需要如下所示的功能
Example : if a have an address 0x13000 i need some function like below
struct vm_area_struct *vma = vma_corresponds_to (0x13000,task);
推荐答案
您正在 linux/mm.h
中寻找 find_vma
.
/* Look up the first VMA which satisfies addr < vm_end, NULL if none. */
extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long addr);
这应该可以解决问题:
struct vm_area_struct *vma = find_vma(task->mm, 0x13000);
if (vma == NULL)
return -EFAULT;
if (0x13000 >= vma->vm_end)
return -EFAULT;
这篇关于LInux内核API查找与虚拟地址相对应的vma的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文