完善了list/rbtree遍历进程虚拟地址空间vm_area_struct的学习代码--驱动print_vmarea

This commit is contained in:
gatieme
2016-07-27 14:29:32 +08:00
parent 1194247152
commit e9f14dfc7d
8 changed files with 1223 additions and 14 deletions
@@ -0,0 +1 @@
cmd_/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.ko := aarch64-linux-gnu-ld -EL -r -T /usr/src/linux-headers-3.14.0-20150821.kylin.3.desktop/scripts/module-common.lds --build-id -o /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.ko /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.o /home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.mod.o
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,2 @@
/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.ko
/home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.o
@@ -0,0 +1 @@
kernel//home/gatieme/Work/GitHub/LDD-LinuxDeviceDrivers/study/kernel/01-process/01-task/print_vmarea/print_vmarea.ko
@@ -65,34 +65,42 @@ void print_vm_file(struct vm_area_struct *vmarea)
//if(p->vm_file->f_path.dentry != NULL)
if(den != NULL)
{
printk("\t");
//for(pPath = p->vm_file->f_path.dentry;
for(pPath = den;
printf("\t");
memset(file,'\0',sizeof(file));
//for(pPath = p->vm_file->f_path.dentry;
for(pPath = den;
pPath != NULL;
pPath = pPath->d_parent)
{
if(strcmp(pPath->d_name.name, "/") != 0)
{
printk("%s/", pPath->d_name.name);
strcpy(file + strlen(file), pPath->d_name.name);
strcpy(file + strlen(file), "/");
continue;
}
break;
}
/*
do
{
end = file + strlen(file) - 1;
for(start = end - 1; *start != '/' && start > file; start--);
if(*start == '/') {start++;}
*end = '\0';
printk("/%s", start);
*start = '\0';
} while(start > file);*/
}
}
for(start = end - 1; *start != '/' && start > file; start--);
//printk("%c", DELIMITER);
if(*start == '/')
{
start++;
}
*end = '\0';
printk("/%s", start);
*start = '\0';
} while(start > file);
}
}
}
void print_vmraea_node(struct vm_area_struct *vmnode)
@@ -0,0 +1,32 @@
#include <linux/module.h>
#include <linux/vermagic.h>
#include <linux/compiler.h>
MODULE_INFO(vermagic, VERMAGIC_STRING);
__visible struct module __this_module
__attribute__((section(".gnu.linkonce.this_module"))) = {
.name = KBUILD_MODNAME,
.init = init_module,
#ifdef CONFIG_MODULE_UNLOAD
.exit = cleanup_module,
#endif
.arch = MODULE_ARCH_INIT,
};
static const struct modversion_info ____versions[]
__used
__attribute__((section("__versions"))) = {
{ 0x146be775, __VMLINUX_SYMBOL_STR(module_layout) },
{ 0xb6b46a7c, __VMLINUX_SYMBOL_STR(param_ops_int) },
{ 0x7344e2ef, __VMLINUX_SYMBOL_STR(pid_task) },
{ 0x8e9cdd4c, __VMLINUX_SYMBOL_STR(find_vpid) },
{ 0xe2d5255a, __VMLINUX_SYMBOL_STR(strcmp) },
{ 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) },
};
static const char __module_depends[]
__used
__attribute__((section(".modinfo"))) =
"depends=";