Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- logger "Hello"
- dmesg
- #include <linux/module.h>
- #include <linux/kernel.h>
- int init_module(void)
- {
- printk(KERN_INFO "Hello worldn");
- return 0;
- }
- void cleanup_module(void)
- {
- printk(KERN_INFO "Goodbye worldn");
- }
- obj-m += hello.o
- all:
- make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
- $ make
- $ sudo insmod hello.ko
- $ dmesg | tail -n1
- [7089996.746366] Hello world
- fixnum:~# echo Some message > /dev/kmsg
- fixnum:~# dmesg | tail -n1
- [28078118.692242] Some message
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/proc_fs.h>
- #include <asm/uaccess.h>
- static int pk_write(struct file *file, const char *buffer, unsigned long count, void *data)
- {
- char string[256];
- count = count < 255 ? count : 255;
- if(copy_from_user(string, buffer, count))
- return -EFAULT;
- string[count] = '