- int __block_write_begin(struct page *page, loff_t pos, unsigned len,
- get_block_t *get_block)
- {
- 。。。
- blocksize = 1 << inode->i_blkbits;
- if (!page_has_buffers(page))
- create_empty_buffers(page, blocksize, 0);
- head = page_buffers(page);
- bbits = inode->i_blkbits;
- block = (sector_t)page->index << (PAGE_CACHE_SHIFT - bbits);
- 。。。
- }
- struct pt_regs {
- unsigned long r15;
- unsigned long r14;
- unsigned long r13;
- unsigned long r12;
- unsigned long rbp;
- unsigned long rbx;
- /* arguments: non interrupts/non tracing syscalls only save upto here*/
- unsigned long r11;
- unsigned long r10;
- unsigned long r9;
- unsigned long r8;
- unsigned long rax;
- unsigned long rcx;
- unsigned long rdx;
- unsigned long rsi;
- unsigned long rdi;
- unsigned long orig_rax;
- /* end of arguments */
- /* cpu exception frame or undefined */
- unsigned long rip;
- unsigned long cs;
- unsigned long eflags;
- unsigned long rsp;
- unsigned long ss;
- /* top of stack page */
- };
- struct pt_regs {
- unsigned long r15;
- unsigned long r14;
- unsigned long r13;
- unsigned long r12;
- unsigned long bp;
- unsigned long bx;
- /* arguments: non interrupts/non tracing syscalls only save up to here*/
- unsigned long r11;
- unsigned long r10;
- unsigned long r9;
- unsigned long r8;
- unsigned long ax;
- unsigned long cx;
- unsigned long dx;
- unsigned long si;
- unsigned long di;
- unsigned long orig_ax;
- /* end of arguments */
- /* cpu exception frame or undefined */
- unsigned long ip;
- unsigned long cs;
- unsigned long flags;
- unsigned long sp;
- unsigned long ss;
- /* top of stack page */
- };
- /*
- * kprobe_jiffies.c
- */
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/string.h>
- #include <linux/init.h>
- #include <linux/kprobes.h>
- #include <linux/kallsyms.h>
- #include "asm/ptrace.h"
- #include "asm/current.h"
- #include "linux/utsname.h"
- /* global probe object */
- struct kprobe probe;
- /*
- * enter the probe pointer
- */
- static int pre_probe(struct kprobe *probe, struct pt_regs *regs)
- {
- printk("block_size = %d.\n", regs->si);
- return 0;
- }
- /*
- * exit the probe pointer
- */
- static void post_probe(struct kprobe *probe, struct pt_regs *regs, unsigned long flags)
- {}
- static int __init kprobe_ init(void)
- {
- probe.pre_handler = pre_probe;
- probe.post_handler = post_probe;
- probe.addr = (kprobe_opcode_t *) kallsyms_lookup_name("create_empty_buffers");
- if (probe.addr == NULL) {
- return 1;
- }
- register_kprobe(&probe);
- printk("register probe driver.\n");
- return 0;
- }
- static void __exit kprobe_exit(void)
- {
- unregister_kprobe(&probe);
- printk("unregister probe driver.\n");
- return;
- }
- module_init(kprobe_ init);
- module_exit(kprobe_ exit);
- MODULE_AUTHOR("xxx");
- MODULE_DESCRIPTION("kernel probe driver");
- MODULE_LICENSE("GPL");