diff --git a/index.html b/index.html
index 7206668..b6e5ffd 100644
--- a/index.html
+++ b/index.html
@@ -18,7 +18,7 @@
The Linux Kernel Module Programming Guide
Peter Jay Salzman, Michael Burian, Ori Pomerantz, Bob Mottram, Jim Huang
-October 26, 2024
+November 5, 2024
@@ -2552,47 +2552,48 @@ accessible via sysfs is given below.
42
43 error = sysfs_create_file(mymodule, &myvariable_attribute.attr);
44 if (error) {
-45 pr_info("failed to create the myvariable file "
-46 "in /sys/kernel/mymodule\n");
-47 }
-48
-49 return error;
-50}
-51
-52static void __exit mymodule_exit(void)
-53{
-54 pr_info("mymodule: Exit success\n");
-55 kobject_put(mymodule);
-56}
-57
-58module_init(mymodule_init);
-59module_exit(mymodule_exit);
-60
-61MODULE_LICENSE("GPL");
+45 kobject_put(mymodule);
+46 pr_info("failed to create the myvariable file "
+47 "in /sys/kernel/mymodule\n");
+48 }
+49
+50 return error;
+51}
+52
+53static void __exit mymodule_exit(void)
+54{
+55 pr_info("mymodule: Exit success\n");
+56 kobject_put(mymodule);
+57}
+58
+59module_init(mymodule_init);
+60module_exit(mymodule_exit);
+61
+62MODULE_LICENSE("GPL");
Make and install the module:
- 1make
-2sudo insmod hello-sysfs.ko
+ 1make
+2sudo insmod hello-sysfs.ko
Check that it exists:
- 1sudo lsmod | grep hello_sysfs
+ 1sudo lsmod | grep hello_sysfs
What is the current value of myvariable
?
- 1sudo cat /sys/kernel/mymodule/myvariable
+ 1sudo cat /sys/kernel/mymodule/myvariable
Set the value of myvariable
and check that it changed.
- 1echo "32" | sudo tee /sys/kernel/mymodule/myvariable
-2sudo cat /sys/kernel/mymodule/myvariable
+ 1echo "32" | sudo tee /sys/kernel/mymodule/myvariable
+2sudo cat /sys/kernel/mymodule/myvariable
Finally, remove the test module:
- 1sudo rmmod hello_sysfs
+ 1sudo rmmod hello_sysfs
diff --git a/lkmpg-for-ht.html b/lkmpg-for-ht.html
index 7206668..b6e5ffd 100644
--- a/lkmpg-for-ht.html
+++ b/lkmpg-for-ht.html
@@ -18,7 +18,7 @@
The Linux Kernel Module Programming Guide
Peter Jay Salzman, Michael Burian, Ori Pomerantz, Bob Mottram, Jim Huang
-October 26, 2024
+November 5, 2024
@@ -2552,47 +2552,48 @@ accessible via sysfs is given below.
42
43 error = sysfs_create_file(mymodule, &myvariable_attribute.attr);
44 if (error) {
-45 pr_info("failed to create the myvariable file "
-46 "in /sys/kernel/mymodule\n");
-47 }
-48
-49 return error;
-50}
-51
-52static void __exit mymodule_exit(void)
-53{
-54 pr_info("mymodule: Exit success\n");
-55 kobject_put(mymodule);
-56}
-57
-58module_init(mymodule_init);
-59module_exit(mymodule_exit);
-60
-61MODULE_LICENSE("GPL");
+45 kobject_put(mymodule);
+46 pr_info("failed to create the myvariable file "
+47 "in /sys/kernel/mymodule\n");
+48 }
+49
+50 return error;
+51}
+52
+53static void __exit mymodule_exit(void)
+54{
+55 pr_info("mymodule: Exit success\n");
+56 kobject_put(mymodule);
+57}
+58
+59module_init(mymodule_init);
+60module_exit(mymodule_exit);
+61
+62MODULE_LICENSE("GPL");
Make and install the module:
- 1make
-2sudo insmod hello-sysfs.ko
+ 1make
+2sudo insmod hello-sysfs.ko
Check that it exists:
- 1sudo lsmod | grep hello_sysfs
+ 1sudo lsmod | grep hello_sysfs
What is the current value of myvariable
?
- 1sudo cat /sys/kernel/mymodule/myvariable
+ 1sudo cat /sys/kernel/mymodule/myvariable
Set the value of myvariable
and check that it changed.
- 1echo "32" | sudo tee /sys/kernel/mymodule/myvariable
-2sudo cat /sys/kernel/mymodule/myvariable
+ 1echo "32" | sudo tee /sys/kernel/mymodule/myvariable
+2sudo cat /sys/kernel/mymodule/myvariable
Finally, remove the test module:
- 1sudo rmmod hello_sysfs
+ 1sudo rmmod hello_sysfs