Created
May 24, 2013 05:06
-
-
Save hiboma/5641371 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| obj-m := sekigae.o | |
| KDIR := /lib/modules/$(shell uname -r)/build | |
| PWD := $(shell pwd) | |
| all: | |
| $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules | |
| clean: | |
| rm -rf *.o *.ko *.mod.c *~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <linux/module.h> | |
| #include <linux/kernel.h> | |
| #include <linux/random.h> | |
| MODULE_DESCRIPTION("Sekigae Module"); | |
| MODULE_AUTHOR("Sekigae"); | |
| MODULE_LICENSE("SUSHI"); | |
| static int sekigae_init_module(void) | |
| { | |
| const char *newcomers[] = { | |
| "okkun", | |
| "keoken", | |
| "kitak", | |
| "gussan", | |
| }; | |
| int i; | |
| unsigned int members_count = sizeof(newcomers) / sizeof(char *); | |
| printk("sekigae module is loaded.\n"); | |
| for (i = 0; i < members_count; i++) { | |
| char *swapped; | |
| unsigned int r; | |
| get_random_bytes(&r, sizeof r); | |
| r = r % members_count; | |
| swapped = newcomers[r]; | |
| newcomers[r] = newcomers[i]; | |
| newcomers[i] = swapped; | |
| } | |
| for (i = 0; i < members_count; i++) { | |
| printk("%s\n", newcomers[i]); | |
| } | |
| return 0; | |
| } | |
| static void sekigae_cleanup_module(void) | |
| { | |
| printk("sekigae module is unloaded.\n"); | |
| } | |
| module_init(sekigae_init_module); | |
| module_exit(sekigae_cleanup_module); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment