deploy: af8a3e657230197975a54a83c0c3ada52fec3fe8

This commit is contained in:
jserv 2024-11-11 11:54:37 +00:00
parent f2b3b7c065
commit 1e3bae16a9
2 changed files with 20 additions and 20 deletions

View File

@ -201,15 +201,15 @@ desired.
<code> <span class='ectt-1000'>lsmod</span>
</code>.
</p>
<pre class='fancyvrb' id='fancyvrb3'><a id='x1-6004r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod</span></pre>
<pre class='fancyvrb' id='fancyvrb3'><a id='x1-6004r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod</span></pre>
<!-- l. 139 --><p class='indent'> Modules are stored within the file <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>/proc/modules</span></span></span>, so you can also see them with:
</p>
<pre class='fancyvrb' id='fancyvrb4'><a id='x1-6007r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo cat /proc/modules</span></pre>
<pre class='fancyvrb' id='fancyvrb4'><a id='x1-6007r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>cat /proc/modules</span></pre>
<!-- l. 144 --><p class='indent'> This can be a long list, and you might prefer to search for something particular.
To search for the <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>fat</span></span></span> module:
</p>
<pre class='fancyvrb' id='fancyvrb5'><a id='x1-6010r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep fat</span></pre>
<pre class='fancyvrb' id='fancyvrb5'><a id='x1-6010r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep fat</span></pre>
<!-- l. 150 --><p class='noindent'>
</p>
<h4 class='subsectionHead' id='is-there-a-need-to-download-and-compile-the-kernel'><span class='titlemark'>1.6 </span> <a id='x1-70001.6'></a>Is there a need to download and compile the kernel?</h4>
@ -473,13 +473,13 @@ module. You can find info on it with the command:
<pre class='fancyvrb' id='fancyvrb19'><a id='x1-12139r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>modinfo hello-1.ko</span></pre>
<!-- l. 371 --><p class='indent'> At this point the command:
</p>
<pre class='fancyvrb' id='fancyvrb20'><a id='x1-12142r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello</span></pre>
<pre class='fancyvrb' id='fancyvrb20'><a id='x1-12142r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello</span></pre>
<!-- l. 376 --><p class='indent'> should return nothing. You can try loading your shiny new module with:
</p>
<pre class='fancyvrb' id='fancyvrb21'><a id='x1-12145r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo insmod hello-1.ko</span></pre>
<!-- l. 382 --><p class='indent'> The dash character will get converted to an underscore, so when you again try:
</p>
<pre class='fancyvrb' id='fancyvrb22'><a id='x1-12148r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello</span></pre>
<pre class='fancyvrb' id='fancyvrb22'><a id='x1-12148r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello</span></pre>
<!-- l. 387 --><p class='indent'> You should now see your loaded module. It can be removed again with:
</p>
<pre class='fancyvrb' id='fancyvrb23'><a id='x1-12151r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo rmmod hello_1</span></pre>
@ -489,7 +489,7 @@ the logs:
</p>
<pre class='fancyvrb' id='fancyvrb24'><a id='x1-12154r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo journalctl --since </span><span id='textcolor43'><span class='ectt-1000'>"1 hour ago"</span></span><span class='ectt-1000'> | grep kernel</span></pre>
<pre class='fancyvrb' id='fancyvrb24'><a id='x1-12154r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>journalctl --since </span><span id='textcolor43'><span class='ectt-1000'>"1 hour ago"</span></span><span class='ectt-1000'> | grep kernel</span></pre>
<!-- l. 398 --><p class='indent'> You now know the basics of creating, compiling, installing and removing modules.
Now for more of a description of how this module works.
</p><!-- l. 401 --><p class='indent'> Kernel modules must have at least two functions: a "start" (initialization) function
@ -1596,7 +1596,7 @@ positive.
which keeps track of how many processes are using your module. You
can see what its value is by looking at the 3rd field with the command
<code> <span class='ectt-1000'>cat /proc/modules</span>
</code> or <code> <span class='ectt-1000'>sudo lsmod</span>
</code> or <code> <span class='ectt-1000'>lsmod</span>
</code>. If this number isn’t zero, <code> <span class='ectt-1000'>rmmod</span>
</code> will fail. Note that you do not have to check the counter within
<code> <span class='ectt-1000'>cleanup_module</span>
@ -2578,18 +2578,18 @@ accessible via sysfs is given below.
<!-- l. 1340 --><p class='indent'> Check that it exists:
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb56'><a id='x1-38196r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello_sysfs</span></pre>
<pre class='fancyvrb' id='fancyvrb56'><a id='x1-38196r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello_sysfs</span></pre>
<!-- l. 1346 --><p class='indent'> What is the current value of <code> <span class='ectt-1000'>myvariable</span>
</code> ?
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb57'><a id='x1-38200r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo cat /sys/kernel/mymodule/myvariable</span></pre>
<pre class='fancyvrb' id='fancyvrb57'><a id='x1-38200r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>cat /sys/kernel/mymodule/myvariable</span></pre>
<!-- l. 1352 --><p class='indent'> Set the value of <code> <span class='ectt-1000'>myvariable</span>
</code> and check that it changed.
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb58'><a id='x1-38205r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>echo </span><span id='textcolor1046'><span class='ectt-1000'>"32"</span></span><span class='ectt-1000'> | sudo tee /sys/kernel/mymodule/myvariable</span>
<a id='x1-38207r2'></a><span class='ecrm-0500'>2</span><span class='ectt-1000'>sudo cat /sys/kernel/mymodule/myvariable</span></pre>
<a id='x1-38207r2'></a><span class='ecrm-0500'>2</span><span class='ectt-1000'>cat /sys/kernel/mymodule/myvariable</span></pre>
<!-- l. 1359 --><p class='indent'> Finally, remove the test module:
</p><!-- l. 1 --><p class='indent'>
</p>

View File

@ -201,15 +201,15 @@ desired.
<code> <span class='ectt-1000'>lsmod</span>
</code>.
</p>
<pre class='fancyvrb' id='fancyvrb3'><a id='x1-6004r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod</span></pre>
<pre class='fancyvrb' id='fancyvrb3'><a id='x1-6004r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod</span></pre>
<!-- l. 139 --><p class='indent'> Modules are stored within the file <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>/proc/modules</span></span></span>, so you can also see them with:
</p>
<pre class='fancyvrb' id='fancyvrb4'><a id='x1-6007r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo cat /proc/modules</span></pre>
<pre class='fancyvrb' id='fancyvrb4'><a id='x1-6007r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>cat /proc/modules</span></pre>
<!-- l. 144 --><p class='indent'> This can be a long list, and you might prefer to search for something particular.
To search for the <span class='obeylines-h'><span class='verb'><span class='ectt-1000'>fat</span></span></span> module:
</p>
<pre class='fancyvrb' id='fancyvrb5'><a id='x1-6010r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep fat</span></pre>
<pre class='fancyvrb' id='fancyvrb5'><a id='x1-6010r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep fat</span></pre>
<!-- l. 150 --><p class='noindent'>
</p>
<h4 class='subsectionHead' id='is-there-a-need-to-download-and-compile-the-kernel'><span class='titlemark'>1.6 </span> <a id='x1-70001.6'></a>Is there a need to download and compile the kernel?</h4>
@ -473,13 +473,13 @@ module. You can find info on it with the command:
<pre class='fancyvrb' id='fancyvrb19'><a id='x1-12139r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>modinfo hello-1.ko</span></pre>
<!-- l. 371 --><p class='indent'> At this point the command:
</p>
<pre class='fancyvrb' id='fancyvrb20'><a id='x1-12142r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello</span></pre>
<pre class='fancyvrb' id='fancyvrb20'><a id='x1-12142r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello</span></pre>
<!-- l. 376 --><p class='indent'> should return nothing. You can try loading your shiny new module with:
</p>
<pre class='fancyvrb' id='fancyvrb21'><a id='x1-12145r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo insmod hello-1.ko</span></pre>
<!-- l. 382 --><p class='indent'> The dash character will get converted to an underscore, so when you again try:
</p>
<pre class='fancyvrb' id='fancyvrb22'><a id='x1-12148r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello</span></pre>
<pre class='fancyvrb' id='fancyvrb22'><a id='x1-12148r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello</span></pre>
<!-- l. 387 --><p class='indent'> You should now see your loaded module. It can be removed again with:
</p>
<pre class='fancyvrb' id='fancyvrb23'><a id='x1-12151r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo rmmod hello_1</span></pre>
@ -489,7 +489,7 @@ the logs:
</p>
<pre class='fancyvrb' id='fancyvrb24'><a id='x1-12154r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo journalctl --since </span><span id='textcolor43'><span class='ectt-1000'>"1 hour ago"</span></span><span class='ectt-1000'> | grep kernel</span></pre>
<pre class='fancyvrb' id='fancyvrb24'><a id='x1-12154r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>journalctl --since </span><span id='textcolor43'><span class='ectt-1000'>"1 hour ago"</span></span><span class='ectt-1000'> | grep kernel</span></pre>
<!-- l. 398 --><p class='indent'> You now know the basics of creating, compiling, installing and removing modules.
Now for more of a description of how this module works.
</p><!-- l. 401 --><p class='indent'> Kernel modules must have at least two functions: a "start" (initialization) function
@ -1596,7 +1596,7 @@ positive.
which keeps track of how many processes are using your module. You
can see what its value is by looking at the 3rd field with the command
<code> <span class='ectt-1000'>cat /proc/modules</span>
</code> or <code> <span class='ectt-1000'>sudo lsmod</span>
</code> or <code> <span class='ectt-1000'>lsmod</span>
</code>. If this number isn’t zero, <code> <span class='ectt-1000'>rmmod</span>
</code> will fail. Note that you do not have to check the counter within
<code> <span class='ectt-1000'>cleanup_module</span>
@ -2578,18 +2578,18 @@ accessible via sysfs is given below.
<!-- l. 1340 --><p class='indent'> Check that it exists:
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb56'><a id='x1-38196r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo lsmod | grep hello_sysfs</span></pre>
<pre class='fancyvrb' id='fancyvrb56'><a id='x1-38196r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>lsmod | grep hello_sysfs</span></pre>
<!-- l. 1346 --><p class='indent'> What is the current value of <code> <span class='ectt-1000'>myvariable</span>
</code> ?
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb57'><a id='x1-38200r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>sudo cat /sys/kernel/mymodule/myvariable</span></pre>
<pre class='fancyvrb' id='fancyvrb57'><a id='x1-38200r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>cat /sys/kernel/mymodule/myvariable</span></pre>
<!-- l. 1352 --><p class='indent'> Set the value of <code> <span class='ectt-1000'>myvariable</span>
</code> and check that it changed.
</p><!-- l. 1 --><p class='indent'>
</p>
<pre class='fancyvrb' id='fancyvrb58'><a id='x1-38205r1'></a><span class='ecrm-0500'>1</span><span class='ectt-1000'>echo </span><span id='textcolor1046'><span class='ectt-1000'>"32"</span></span><span class='ectt-1000'> | sudo tee /sys/kernel/mymodule/myvariable</span>
<a id='x1-38207r2'></a><span class='ecrm-0500'>2</span><span class='ectt-1000'>sudo cat /sys/kernel/mymodule/myvariable</span></pre>
<a id='x1-38207r2'></a><span class='ecrm-0500'>2</span><span class='ectt-1000'>cat /sys/kernel/mymodule/myvariable</span></pre>
<!-- l. 1359 --><p class='indent'> Finally, remove the test module:
</p><!-- l. 1 --><p class='indent'>
</p>