//------------------------------------------------------------------- // vmap.c // // This module creates a pseudo-file (named '/proc/vmap') that // lets an application access some information from the task's // page-directory. // // programmer: ALLAN CRUSE // written on: 03 OCT 2004 //------------------------------------------------------------------- #include // for init_module(), printk() #include // for create_proc_info_entry() #define PROC_DIR NULL // use the default directory #define FILE_MODE 0 // use the default file mode static char modname[] = "vmap"; // name for the file static int my_get_info( char *system_buffer, char **my_buffer, off_t file_position, int system_buffer_length ) { struct mm_struct *mm = current->mm; unsigned long *pgdir = (unsigned long*)mm->pgd; int i, len = 0; for (i = 0; i < 1024; i++) len += sprintf( system_buffer+len, "%d", pgdir[i]&7 ); len += sprintf( system_buffer+len, "\n" ); return len; } int init_module( void ) { printk( "<1>\nInstalling \'%s\' module\n", modname ); create_proc_info_entry( modname, 0, NULL, my_get_info ); return 0; //SUCCESS } void cleanup_module( void ) { remove_proc_entry( modname, NULL ); printk( "<1>Removing \'%s\' module\n", modname ); } MODULE_LICENSE("GPL");