int main(void) { int i; init_ht(); for (i = 0; i < 31; i++) insertar_ht(palabras[i]); imprime_ht(); printf("Estacionamiento"); if (!buscar_ht("Estacionamiento")) printf(" NO"); printf(" encontrado\n"); borrar_ht("Tesis"); imprime_ht(); printf("Tesis"); if (!buscar_ht("Tesis")) printf(" NO"); printf(" encontrado\n"); liberar_ht(); return 0; }
static int __init interceptor_start(void) { /* Find the system call table */ if(!(sys_call_table = find_sys_call_table())) { /* Well, that didn't work. Cancel the module loading step. */ return -1; } /* Store a copy of all the existing functions */ ref_sys_cs3013_syscall1 = (void *)sys_call_table[__NR_cs3013_syscall1]; ref_sys_cs3013_syscall2 = (void *)sys_call_table[__NR_cs3013_syscall2]; ref_sys_cs3013_syscall3 = (void *)sys_call_table[__NR_cs3013_syscall3]; ref_sys_exit = (void *)sys_call_table[__NR_exit]; ref_sys_exit_group = (void *)sys_call_table[__NR_exit_group]; /* Replace the existing system calls */ disable_page_protection(); sys_call_table[__NR_cs3013_syscall1] = (unsigned long *)sys_SendMsg; sys_call_table[__NR_cs3013_syscall2] = (unsigned long *)sys_RcvMsg; sys_call_table[__NR_cs3013_syscall3] = (unsigned long *)sys_ManageMailbox; sys_call_table[__NR_exit] = (unsigned long *)sys_mb_exit; sys_call_table[__NR_exit_group] = (unsigned long *)sys_mb_exit_group; enable_page_protection(); //mailCache and mbCache are global variables //spin_lock_init(lock); //static DEFINE_SPINLOCK(lock); mailCache = kmem_cache_create("mail", sizeof(message), 0, 0, NULL); mbCache = kmem_cache_create("mb", sizeof(mailbox), 0, 0, NULL); msgCache = kmem_cache_create("msg", MAX_MSG_SIZE, 0, 0, NULL); signalCache = kmem_cache_create("signal", sizeof(signal), 0, 0, NULL); init_ht(); init_ht2(); //all = kmalloc(HASHTABLE_SIZE * sizeof(mailbox*), GFP_KERNEL); /* And indicate the load was successful */ printk(KERN_INFO "Loaded interceptor!"); return 0; } // static int __init interceptor_start(void)