然后,将这个函数设置到 vm_operations_struct 中: static struct vm_operations_struct my_vm_ops = { .access = my_vma_access, }; static int my_device_mmap(struct file *filp, struct vm_area_struct *vma) { vma->vm_ops = &my_vm_ops; return 0; } 完整示例 #include <linux/uaccess.h> ...
参数:struct vm_fault *vmf,包含页面错误的详细信息。 说明:用于处理物理页帧(PFN)的写入保护。 access 作用:当 get_user_pages() 失败时由access_process_vm调用。 参数:struct vm_area_struct *vma,指向虚拟内存区域的结构体;unsigned long addr,地址;void *buf,缓冲区;int len,长度;int write,是否写入。
" 文件映射 " 的 " 虚拟内存区域 " vm_area_struct 结构体 的 数据结构表示形式如下 ; 1、文件映射 虚拟内存区域 的 vm_ops 成员 vm_area_struct 结构体 中的 const struct vm_operations_struct *vm_ops; 成员, 指向 虚拟内存操作集合 vm_operations_struct 类型的实例 ; vm_ops 成员是 " 虚拟内存操作...
*/struct vm_operations_struct{void(*open)(struct vm_area_struct*area);void(*close)(struct vm_area_struct*area);int(*mremap)(struct vm_area_struct*area);int(*fault)(struct vm_fault*vmf);int(*huge_fault)(struct vm_fault*vmf,enumpage_entry_size pe_size);void(*map_pages)(struct vm_f...
struct vm_operations_struct * vm_ops; /* 后备存储器的有关信息: */ unsigned long vm_pgoff; /* (vm_file内)的偏移量,单位是PAGE_SIZE,不是PAGE_CACHE_SIZE */ struct file * vm_file; /* 映射到的文件(可能是NULL)。 */ void * vm_private_data; /* vm_pte(即共享内存) */ ...
vm_area_struct 结构含有指向vm_operations_struct 结构的一个指针,vm_operations_struct 描述了在这个区间的操作。vm_operations 结构中包含的是函数指针;其中,open、close 分别用于虚拟区间的打开、关闭,而nopage 用于当虚存页面不在物理内存而引起的“缺页异常”时所应该调用的函数,当 Linux 处理这一缺页异常时(...
vm_ops成员是 " 虚拟内存操作集合 " , 该vm_operations_struct结构体中封装了大量的虚拟内存操作 ; /* Function pointers to deal with this struct. */ const struct vm_operations_struct *vm_ops; 1. 2. 二、vm_operations_struct 结构体成员分析 ...
vm_operations_struct结构中包好的是函数指针,其中open、close分别用于虚拟内存的打开、关闭,而nopage用于当虚拟内存页面没有实际的物理内存映照而引发的”缺页异常”时所调用的函数指针。 structvm_operations_struct {void(*open)(structvm_area_strucr *area);void(*close)(structvm_area_struct *area);structpa...
structfile *vm_file; unsignedlongvm_raend; void*vm_private_data; }; structvm_operations_struct { void(*open)(structvm_area_struct *area); void(*close)(structvm_area_struct *area); structpage *(*nopage)(structvm_area_struct *area,unsignedlongaddress,intunused); ...
针对虚拟进程地址空间中不同的属性区域由一个个的VMA通过一定方式组织在一起,每个VMA也就是struct vm_area_struct进行表示,比如描述栈这个内存区域也是由一个VMA进行描述其开始地址、结束地址、属性权限等等。 structvm_area_struct{ /* The first cache line has the info for VMA tree walking. ...