Skip to content

Instantly share code, notes, and snippets.

@radix42
Forked from hashbrowncipher/dmesg_rick.c
Created October 11, 2017 01:03
Show Gist options
  • Save radix42/2c0aa486bf071c2f2356d63b885002ba to your computer and use it in GitHub Desktop.
Save radix42/2c0aa486bf071c2f2356d63b885002ba 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