-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hello assignment in skels #11
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
[ $# -ne 1 ] && { echo "Usage: $0 path-hello-world.ko"; exit 1; } | ||
|
||
/bin/dmesg -c > /dev/null 2>&1 | ||
/sbin/rmmod hello-world > /dev/null 2>&1 | ||
/sbin/insmod $1 | ||
/bin/dmesg | grep 'Hello, World!' > /dev/null 2>&1 | ||
if test $? -eq 0; then | ||
echo "Test PASSED." | ||
else | ||
echo "Test FAILED." | ||
fi | ||
/sbin/rmmod hello-world > /dev/null 2>&1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
EXTRA_CFLAGS = -Wall -g -m32 | ||
|
||
obj-m = hello-world.o |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
KDIR=/usr/src/linux-so2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Makefile is not needed anymore, the top level makefile should take care of building |
||
|
||
kbuild: | ||
make -C $(KDIR) M=`pwd` | ||
|
||
clean: | ||
make -C $(KDIR) M=`pwd` clean | ||
|
||
pack: | ||
zip -r hello-world-solution.zip hello-world.c Makefile Kbuild | ||
|
||
deploy: pack | ||
scp hello-world-solution.zip [email protected]:res/current/teme/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <linux/kernel.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please run ./scripts/checkpatch.pl -f --strict hello.c to verify for coding style problems |
||
#include <linux/init.h> | ||
#include <linux/module.h> | ||
|
||
MODULE_DESCRIPTION("Hello World"); | ||
MODULE_AUTHOR("Psoru Lesfo Rever"); | ||
MODULE_LICENSE("GPL"); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are here I think we should also find a better name for module author. I don't have good names now, but I think kernel people recommend to use real names here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree. It should still be a generic name. I recommend we use "Linux Kernel Labs [email protected]", or we can create a new e-mail address. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the same author for all modules. I suggest changing this for all modules in a future commit. |
||
|
||
static int hello_init(void) | ||
{ | ||
printk(KERN_DEBUG "Hello, World!\n"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to avoid using printk where possible, it is now recommended to use pr_debug, pr_info, etc. I think we can replace this with pr_info. Also, I think we should add a TODO comment here so that this line is removed when the skel is generated. |
||
return 0; | ||
} | ||
|
||
static void hello_exit(void) | ||
{ | ||
} | ||
|
||
module_init(hello_init); | ||
module_exit(hello_exit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the extra sol directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be called
hello-world
.I assumed this as the source directory, it can have any name.
checker
directory is supposed to exist in order to be recursively copied to vm disdk