summaryrefslogtreecommitdiff
path: root/hello/hello-3.c
diff options
context:
space:
mode:
author0xwille2011-06-24 13:57:37 +0200
committer0xwille2011-06-24 13:57:37 +0200
commitc73b83935734bf0a9b56183a2535dd0daba221fe (patch)
tree17962f67c24fcee8bd0ff292332365294cc366b7 /hello/hello-3.c
downloadlkm-c73b83935734bf0a9b56183a2535dd0daba221fe.tar.gz
Commit inicial
Diffstat (limited to 'hello/hello-3.c')
-rw-r--r--hello/hello-3.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/hello/hello-3.c b/hello/hello-3.c
new file mode 100644
index 0000000..a82e4a4
--- /dev/null
+++ b/hello/hello-3.c
@@ -0,0 +1,50 @@
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/stat.h>
+
+static short int myshort = 1;
+static int myint = 420;
+static long int mylong = 9999;
+static char* mystring = "blah";
+static int myintArray[2] = {-1, -1};
+static int arr_argc = 0;
+
+module_param(myshort, short, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
+MODULE_PARM_DESC(myshort, "A short integer");
+module_param(myint, int, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
+MODULE_PARM_DESC(myint, "An integer");
+module_param(mylong, long, S_IRUSR);
+MODULE_PARM_DESC(mylong, "A long integer");
+module_param(mystring, charp, 0000);
+MODULE_PARM_DESC(mystring, "A character string");
+
+module_param_array(myintArray, int, &arr_argc, 0000);
+MODULE_PARM_DESC(myintArray, "An array of integers");
+
+static int __init hello_3_init(void)
+{
+ int i;
+ printk(KERN_INFO "Hola, mundo! 3\n============\n");
+ printk(KERN_INFO "myshort is a short integer: %hd\n", myshort);
+ printk(KERN_INFO "myint is an integer: %d\n", myint);
+ printk(KERN_INFO "mylong is a long integer: %ld\n", mylong);
+ printk(KERN_INFO "mystring is a string: %s\n", mystring);
+ for (i = 0; i < sizeof(myintArray)/sizeof(int); i++)
+ printk(KERN_INFO "myintArray[%d] = %d\n", i, myintArray[i]);
+ printk(KERN_INFO "got %d arguments for myintArray\n", arr_argc);
+ return 0;
+}
+
+static void __exit hello_3_exit(void)
+{
+ printk(KERN_INFO "Adiós, mundo! 3\n============\n");
+}
+
+module_init(hello_3_init);
+module_exit(hello_3_exit);
+
+MODULE_AUTHOR("Guillermo Ramos");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Módulo tonto");