Skip to content

Instantly share code, notes, and snippets.

@hashbrowncipher
Created October 10, 2017 23:32
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hashbrowncipher/426c39c87a6675374fad3015d4481f02 to your computer and use it in GitHub Desktop.
Save hashbrowncipher/426c39c87a6675374fad3015d4481f02 to your computer and use it in GitHub Desktop.
#include <linux/hrtimer.h>
#include <linux/module.h>
#include <linux/kernel.h>
static struct hrtimer timer;
enum hrtimer_restart yell_rick( struct hrtimer *timer )
{
ktime_t time;
printk(KERN_INFO "I turned myself into a logger morty! I'm dmesg RIIIICK!\n");
time = ktime_set(0, 1E9L);
hrtimer_forward_now(timer, time);
return HRTIMER_RESTART;
}
static int __init init_rick(void)
{
ktime_t time;
printk(KERN_INFO "morty! Morty! MORRRTY!\n");
time = ktime_set(0, 1E9L);
hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
timer.function = yell_rick;
hrtimer_start(&timer, time, HRTIMER_MODE_REL);
return 0;
}
static void __exit exit_rick(void)
{
hrtimer_cancel(&timer);
printk(KERN_INFO "This is the mega-genius equivalent of dying on the toilet.\n");
}
MODULE_LICENSE("Dual MIT/GPL");
module_init(init_rick);
module_exit(exit_rick);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment