Skip to content

Commit

Permalink
add hello kmod
Browse files Browse the repository at this point in the history
  • Loading branch information
daveti committed Dec 31, 2018
1 parent bf322cc commit ecf9844
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions kmod/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Makefile supports different kernel path
# Jul 1, 2014
# root@davejingtian.org
# http://davejingtian.org

ifneq ($(KERNELPATH),)
KDIR := $(KERNELPATH)
else
# Default kernel path
KDIR := /lib/modules/$(shell uname -r)/build
endif

PWD := $(shell pwd)

obj-m += hello.o

all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean


26 changes: 26 additions & 0 deletions kmod/hello.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* hello.c
* Dec 30, 2018
* root@davejingtian.org
* http://davejingtian.org
*/
#include <linux/module.h>
#include <linux/kernel.h>


static int __init hello_init(void)
{
pr_info("into %s\n", __func__);
return 0;
}
static void __exit hello_exit(void)
{
pr_info("exit hello module\n");
}

module_init(hello_init);
module_exit(hello_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("hello module");
MODULE_AUTHOR("daveti");

0 comments on commit ecf9844

Please sign in to comment.