1 ////////////////////////////////////////////////////////////////////////////////////
3 // FILE: us_proc_inst.c
6 // This file is C source for SWAP driver.
8 // SEE ALSO: us_proc_inst.h
9 // AUTHOR: A.Gerenkov, E. Gorelkina
10 // COMPANY NAME: Samsung Research Center in Moscow
11 // DEPT NAME: Advanced Software Group
12 // CREATED: 2008.06.02
14 // REVISION DATE: 2008.12.02
16 ////////////////////////////////////////////////////////////////////////////////////
19 #include "us_proc_inst.h"
21 #include "../kprobe/dbi_kprobes_deps.h"
22 #include "../uprobe/swap_uprobes.h"
24 #include "sspt/sspt.h"
26 #include "us_slot_manager.h"
28 #define print_event(fmt, args...) \
31 sprintf(buf, fmt, ##args); \
32 pack_event_info(US_PROBE_ID, RECORD_ENTRY, "ds", 0x0badc0de, buf); \
35 struct dentry *dentry_by_path(const char *path)
37 struct dentry *dentry;
38 #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)
40 if (kern_path(path, LOOKUP_FOLLOW, &st_path) != 0) {
41 #else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
43 if (path_lookup(path, LOOKUP_FOLLOW, &nd) != 0) {
44 #endif /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
45 EPRINTF("failed to lookup dentry for path %s!", path);
49 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
52 #elif LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 38)
53 dentry = nd.path.dentry;
55 #else /* LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38) */
56 dentry = st_path.dentry;
58 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */
62 void print_vma(struct mm_struct *mm);
64 void print_vma(struct mm_struct *mm)
66 struct vm_area_struct *vma;
67 printk("### print_vma: START\n");\
68 printk("### print_vma: START\n");
70 for (vma = mm->mmap; vma; vma = vma->vm_next) {
71 char *x = vma->vm_flags & VM_EXEC ? "x" : "-";
72 char *r = vma->vm_flags & VM_READ ? "r" : "-";
73 char *w = vma->vm_flags & VM_WRITE ? "w" : "-";
74 char *name = vma->vm_file ? (char *)vma->vm_file->f_dentry->d_iname : "N/A";
76 printk("### [%8lx..%8lx] %s%s%s pgoff=\'%8lu\' %s\n",
77 vma->vm_start, vma->vm_end, x, r, w, vma->vm_pgoff, name);
79 printk("### print_vma: END\n");