You don't have javascript enabled. Good luck! :(

This is a test

You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the _posts directory that follows the convention YYYY-MM-DD-name-of-post.ext and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

Jekyll also offers powerful support for code snippets:

def print_hi(name)
  puts "Hi, #{name}"
end
print_hi('Tom')
#=> prints 'Hi, Tom' to STDOUT.

Check out the Jekyll docs for more info on how to get the most out of Jekyll. File all bugs/feature requests at Jekyll’s GitHub repo. If you have questions, you can ask them on Jekyll Talk.

  May 4, 2017     WenYuan     Linux  UPDATE:

寫簡單的 Linux Kernel Module

1. 先創建一個資料夾 並寫個簡單的 kernel module (hello.c)

mkdir helloworld

cd helloworld

vim hello.c
  • hello.c 的 code 如下:
/* hello.c */
#include <linux/init.h>
#include <linux/module.h>
  
MODULE_DESCRIPTION("Hello_world");
MODULE_LICENSE("GPL");
  
static int hello_init(void)
{
 printk(KERN_INFO "Hello world !\n");
 return 0;
}
  
static void hello_exit(void)
{
 printk(KERN_INFO "ByeBye !\n");
}
  
module_init(hello_init);
/* When u use insmod, it will enter hello_init function */

module_exit(hello_exit);
/* When u use rmmod, it will enter hello_exit function */


2. 接著在同個目錄下寫個 Makefile

vim Makefile
  • Makefile 的內容如下:
PWD := $(shell pwd) 
KVERSION := $(shell uname -r)
KERNEL_DIR = /usr/src/linux-headers-$(KVERSION)/
 
MODULE_NAME = hello
obj-m := $(MODULE_NAME).o
 
all: 
 make -C $(KERNEL_DIR) M=$(PWD) modules
clean: 
 make -C $(KERNEL_DIR) M=$(PWD) clean


3. 最後就可以使用 sudo make 指令來編譯

將他編譯成 .ko

sudo make

picture01


4. 使用 insmod 來載入 module

sudo insmod hello.ko

# 載完後用 dmesg 來觀看 kernel 訊息

dmesg

picture02

可以看到成功 print 出 hello world ! 字串


你也可以使用 lsmod 指令來列出目前在使用的 module

# grep "hello" 用來濾出我們的 hello module 

lsmod | grep "hello"

picture03


最後想要移除掉模組的話 要使用 rmmod

sudo rmmod hello.ko

# 再觀察一次 kernel 訊息

dmesg

picture04

可以看到 print 出了 ByeBye ! 字串