//------------------------------------------------------------------- // notifier.c // // This module creates a pseudo-file (named '/proc/notifier') // which shows the 'notifier' and 'notifier_mask' fields from // each task's 'task_struct' object. // // NOTE: Written and tested with Linux kernel version 2.4.26. // // programmer: ALLAN CRUSE // written on: 09 NOV 2004 //------------------------------------------------------------------- #include // for init_module() #include // for create_proc_read_entry() static char modname[] = "notifier"; static int my_get_info( char *buf, char **start, off_t off, int count ) { struct task_struct *tsk = &init_task; int len; len = 0; len += sprintf( buf+len, "\n%s\n", modname ); do { len += sprintf( buf+len, "%15s ", tsk->comm ); len += sprintf( buf+len, "pid=%-5d ", tsk->pid ); len += sprintf( buf+len, "notifier=%08X ", tsk->notifier ); len += sprintf( buf+len, "mask=%08X ", tsk->notifier_mask ); len += sprintf( buf+len, "\n" ); tsk = tsk->next_task; } while ( tsk != &init_task ); len += sprintf( buf+len, "\n" ); return len; } void cleanup_module( void ) { remove_proc_entry( modname, NULL ); printk( "<1>Removing \'%s\' module\n", modname ); } int init_module( void ) { printk( "<1>\nInstalling \'%s\' module\n", modname ); create_proc_info_entry( modname, 0, NULL, my_get_info ); return 0; // SUCCESS } MODULE_LICENSE("GPL");