Created
November 18, 2013 21:18
-
-
Save NeoCat/7535474 to your computer and use it in GitHub Desktop.
にゃんぱすー と表示するカーネルモジュール
使用方法:
make && sudo insmod nyanpasu.ko && cat /dev/renchon
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 = nyanpasu.o | |
all: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | |
clean: | |
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean |
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/miscdevice.h> | |
#include <linux/fs.h> | |
#include <linux/uaccess.h> | |
// AA from http://heno2.com/2ch/v.php?55504 | |
const char data[] = | |
" /⌒\ /⌒\ \n" | |
" // ̄\Y ̄\ヽ \n" | |
" |\/ ̄ ̄ソ ̄\ )ノ \n" | |
"`/⌒ヽ)) /⌒ ⌒\/ヽ \n" | |
"| /⌒ノ/ | V| \n" | |
"| レイ/ /_/| ハ_| V\n" | |
"| |/イ |/イ/ | |レヽ |\n" | |
"| |レ| |┯┯| N┯┯レリ にゃんぱすー\n" | |
"| 人(|||ヒ0ソ |/ ヒ0ソ从| \n" | |
"|| `|从 ` |ノ| \n" | |
"|| || _ ノ || \n" | |
"|| ∧ ヽ─┬< ノ || \n" | |
"|| /\|\/)ヽ フノ| \n" | |
"|| / \_∧_ノヽ| | \n" | |
"||/ ヽ || | \n"; | |
static int nyanpasu_open(struct inode *i, struct file *filp) | |
{ | |
return 0; | |
} | |
static ssize_t nyanpasu_read(struct file *filp, char *buff, | |
size_t len, loff_t *off) | |
{ | |
if (*off) | |
return 0; | |
*off = sizeof(data); | |
return copy_to_user(buff, data, sizeof(data)) ? -EFAULT : sizeof(data); | |
} | |
static int nyanpasu_release(struct inode *inod,struct file *filp) | |
{ | |
return 0; | |
} | |
static struct file_operations fops = | |
{ | |
.open = nyanpasu_open, | |
.release = nyanpasu_release, | |
.read = nyanpasu_read, | |
}; | |
static struct miscdevice nyanpasu_dev = { | |
.name = "renchon", | |
.fops = &fops, | |
.minor = MISC_DYNAMIC_MINOR, | |
.mode = 0444, | |
}; | |
static int nyanpasu_init(void) | |
{ | |
return misc_register(&nyanpasu_dev); | |
} | |
static void nyanpasu_exit(void) | |
{ | |
misc_deregister(&nyanpasu_dev); | |
} | |
MODULE_LICENSE("GPL"); | |
module_init(nyanpasu_init); | |
module_exit(nyanpasu_exit); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment