mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
5530586eec
commit
c7becac0ee
|
@ -4,7 +4,7 @@
|
|||
no longer had time to maintain the document. After all, the Linux kernel is a fast moving target. Peter Jay Salzman took
|
||||
over maintenance and updated it for the 2.4 kernels. Eventually, Peter no longer had time to follow developments with the 2.6
|
||||
kernel, so Michael Burian became a co-maintainer to update the document for the 2.6 kernels.</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
|
||||
|
@ -28,28 +28,35 @@
|
|||
|
||||
<sect1><title>Acknowledgements</title>
|
||||
|
||||
<para>Ori Pomerantz would like to thank Yoav Weiss for many helpful ideas, discussions, and corrections. He would also like
|
||||
to thank Frodo Looijaard from the Netherlands, Stephen Judd from New Zealand, Magnus Ahltorp from Sweeden and Emmanuel
|
||||
Papirakis from Quebec, Canada.</para>
|
||||
|
||||
<para>Peter would also like to thank Ori for letting him take over the LKMPG. He would also like to thank Jeff Newmiller,
|
||||
Rhonda Frances Bailey (who is now Rhonda Frances Salzman) and Mark Kim for teaching him with patience and friendship
|
||||
regardless how busy they were. He would also like to thank David Porter who had the unenviable job of helping convert the
|
||||
original LaTeX source into docbook. It was a long and boring job, but had to be done.</para>
|
||||
|
||||
<para> Thanks also goes to the fine people at <ulink url="www.kernelnewbies.org">www.kernelnewbies.org</ulink>. In
|
||||
particular, Mark McLoughlin and John Levon who I'm sure have much better things to do than to hang out on kernelnewbies.org
|
||||
and teach the newbies. If this guide teaches you anything, they are partially to blame.</para>
|
||||
|
||||
<para>Both Ori and I would like to thank Richard M. Stallman and Linus Torvalds for giving us the opportunity to not only run
|
||||
a high-quality operating system, but to take a close peek at how it works.</para>
|
||||
|
||||
<para>The following people have contributed corrections or good suggestions: Ignacio Martin, David Porter, Daniele Paolo
|
||||
Scarpazza and Dimo Velev</para>
|
||||
Scarpazza, Dimo Velev and Francois Audeon </para>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
||||
<!--
|
||||
This is in the Chinese translation:
|
||||
|
||||
<sect1><title>Note From the Chinese Translator</title>
|
||||
|
||||
<para>I am Jerry Tian, the translator of the simplified Chinese edition of this guide, and now a university student in
|
||||
Beijing. I became a GNU/Linux enthusiast when I first encountered it as a senior high school; I like the spirit of
|
||||
freedom in open source software.</para>
|
||||
|
||||
<para>This guide is the most updated document in Linux kernel module programming. I have also translated the former 2.4
|
||||
branch of LKMPG into simplified Chinese, but based on HTML files, so it's inconvenient to convert it to other formats. Thanks
|
||||
to Peter's advice and encouragement, the translation of 2.6 branch is based on DOCBOOK files, and it's very easy to convert it
|
||||
to other formats like HTML, PDF, etc. Most of its content is from the translation of 2.4 branch, but some translation
|
||||
mistakes in 2.4 branch are corrected. Since I hardly have enough time to go through the 2.4 branch of translation again and
|
||||
correct the mistakes in the HTML files, I suggest if you need to read the simplified translation of 2.4 branch of LKMPG, do
|
||||
refer to the translation of 2.6 branch. Please contact me if you have any ideas on how to improve the simplified Chinese
|
||||
translation of LKMPG or want to help me maintain it.</para>
|
||||
|
||||
<para>My email address is jerrytianbupt@163.com. Learning and sharing the learning is the motive of my translation. I hope
|
||||
you enjoy it! </para>
|
||||
|
||||
</sect1>
|
||||
-->
|
||||
|
||||
|
||||
<!--
|
||||
|
|
|
@ -94,7 +94,15 @@ procfile_read(char *buffer,
|
|||
int init_module()
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
Our_Proc_File = create_proc_entry("test", 0644, NULL);
|
||||
|
||||
if (Our_Proc_File == NULL) {
|
||||
rv = -ENOMEM;
|
||||
remove_proc_entry("test", &proc_root);
|
||||
printk(KERN_INFO "Error: Could not initialize /proc/test\n");
|
||||
}
|
||||
|
||||
Our_Proc_File->read_proc = procfile_read;
|
||||
Our_Proc_File->owner = THIS_MODULE;
|
||||
Our_Proc_File->mode = S_IFREG | S_IRUGO;
|
||||
|
@ -102,16 +110,7 @@ int init_module()
|
|||
Our_Proc_File->gid = 0;
|
||||
Our_Proc_File->size = 37;
|
||||
|
||||
printk(KERN_INFO "Trying to create /proc/test:\n");
|
||||
|
||||
if (Our_Proc_File == NULL) {
|
||||
rv = -ENOMEM;
|
||||
remove_proc_entry("test", &proc_root);
|
||||
printk(KERN_INFO "Error: Could not initialize /proc/test\n");
|
||||
} else {
|
||||
printk(KERN_INFO "Success!\n");
|
||||
}
|
||||
|
||||
printk(KERN_INFO "Created /proc/test:\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -150,8 +150,13 @@ static struct inode_operations Inode_Ops_4_Our_Proc_File = {
|
|||
*/
|
||||
int init_module()
|
||||
{
|
||||
int rv = 0;
|
||||
Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
|
||||
|
||||
if (Our_Proc_File == NULL){
|
||||
printk(KERN_INFO "Error: Could not initialize /proc/test\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
Our_Proc_File->owner = THIS_MODULE;
|
||||
Our_Proc_File->proc_iops = &Inode_Ops_4_Our_Proc_File;
|
||||
Our_Proc_File->proc_fops = &File_Ops_4_Our_Proc_File;
|
||||
|
@ -160,13 +165,7 @@ int init_module()
|
|||
Our_Proc_File->gid = 0;
|
||||
Our_Proc_File->size = 80;
|
||||
|
||||
if (Our_Proc_File == NULL) {
|
||||
rv = -ENOMEM;
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
|
||||
printk(KERN_INFO "Error: Could not initialize /proc/test\n");
|
||||
}
|
||||
|
||||
return rv;
|
||||
return 0; /* success */
|
||||
}
|
||||
|
||||
void cleanup_module()
|
||||
|
|
|
@ -46,15 +46,25 @@ static void print_string(char *str)
|
|||
*
|
||||
* The function's 1st parameter is the tty to write to,
|
||||
* because the same function would normally be used for all
|
||||
* tty's of a certain type. The 2nd parameter controls whether
|
||||
* the function receives a string from kernel memory (false, 0)
|
||||
* or from user memory (true, non zero). The 3rd parameter is
|
||||
* a pointer to a string. The 4th parameter is the length of
|
||||
* the string.
|
||||
* tty's of a certain type. The 2nd parameter controls
|
||||
* whether the function receives a string from kernel
|
||||
* memory (false, 0) or from user memory (true, non zero).
|
||||
* BTW: this param has been removed in Kernels > 2.6.9
|
||||
* The (2nd) 3rd parameter is a pointer to a string.
|
||||
* The (3rd) 4th parameter is the length of the string.
|
||||
*
|
||||
* As you will see below, sometimes it's necessary to use
|
||||
* preprocessor stuff to create code that works for different
|
||||
* kernel versions. The (naive) approach we've taken here
|
||||
* does not scale well. The right way to deal with this
|
||||
* is described in section 2 of
|
||||
* linux/Documentation/SubmittingPatches
|
||||
*/
|
||||
((my_tty->driver)->write) (my_tty, /* The tty itself */
|
||||
#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,9) )
|
||||
0, /* Don't take the string
|
||||
from user space */
|
||||
#endif
|
||||
str, /* String */
|
||||
strlen(str)); /* Length */
|
||||
|
||||
|
@ -72,7 +82,12 @@ static void print_string(char *str)
|
|||
* MS Windows, the ASCII standard was strictly adhered to,
|
||||
* and therefore a newline requirs both a LF and a CR.
|
||||
*/
|
||||
|
||||
#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,9) )
|
||||
((my_tty->driver)->write) (my_tty, 0, "\015\012", 2);
|
||||
#else
|
||||
((my_tty->driver)->write) (my_tty, "\015\012", 2);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,19 +116,20 @@ int __init init_module()
|
|||
queue_delayed_work(my_workqueue, &Task, 100);
|
||||
|
||||
Our_Proc_File = create_proc_entry(PROC_ENTRY_FILENAME, 0644, NULL);
|
||||
Our_Proc_File->read_proc = procfile_read;
|
||||
Our_Proc_File->owner = THIS_MODULE;
|
||||
Our_Proc_File->mode = S_IFREG | S_IRUGO;
|
||||
Our_Proc_File->uid = 0;
|
||||
Our_Proc_File->gid = 0;
|
||||
Our_Proc_File->size = 80;
|
||||
|
||||
if (Our_Proc_File == NULL) {
|
||||
rv = -ENOMEM;
|
||||
remove_proc_entry(PROC_ENTRY_FILENAME, &proc_root);
|
||||
printk(KERN_INFO "Error: Could not initialize /proc/%s\n",
|
||||
PROC_ENTRY_FILENAME);
|
||||
}
|
||||
|
||||
|
||||
Our_Proc_File->read_proc = procfile_read;
|
||||
Our_Proc_File->owner = THIS_MODULE;
|
||||
Our_Proc_File->mode = S_IFREG | S_IRUGO;
|
||||
Our_Proc_File->uid = 0;
|
||||
Our_Proc_File->gid = 0;
|
||||
Our_Proc_File->size = 80;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
</authorgroup>
|
||||
|
||||
<!-- year-month-day -->
|
||||
<pubdate>2004-05-16 ver 2.6.0</pubdate>
|
||||
<pubdate>2005-01-23 ver 2.6.1</pubdate>
|
||||
|
||||
|
||||
<copyright>
|
||||
|
@ -38,29 +38,33 @@
|
|||
</copyright>
|
||||
|
||||
<legalnotice>
|
||||
<para>The Linux Kernel Module Programming Guide is a free book; you may reproduce and/or modify it under the terms of the
|
||||
Open Software License, version 1.1. You can obtain a copy of this license at <ulink
|
||||
<para>The Linux Kernel Module Programming Guide is a free book; you may reproduce and/or
|
||||
modify it under the terms of the Open Software License, version 1.1. You can obtain a copy of
|
||||
this license at <ulink
|
||||
url="http://opensource.org/licenses/osl.php">http://opensource.org/licenses/osl.php</ulink>.</para>
|
||||
|
||||
<para>This book is distributed in the hope it will be useful, but without any warranty, without even the implied warranty
|
||||
of merchantability or fitness for a particular purpose.</para>
|
||||
<para>This book is distributed in the hope it will be useful, but without any warranty,
|
||||
without even the implied warranty of merchantability or fitness for a particular
|
||||
purpose.</para>
|
||||
|
||||
<para>The author encourages wide distribution of this book for personal or commercial use, provided the above copyright
|
||||
notice remains intact and the method adheres to the provisions of the Open Software License. In summary, you may copy and
|
||||
distribute this book free of charge or for a profit. No explicit permission is required from the author for reproduction
|
||||
of this book in any medium, physical or electronic.</para>
|
||||
<para>The author encourages wide distribution of this book for personal or commercial use,
|
||||
provided the above copyright notice remains intact and the method adheres to the provisions of
|
||||
the Open Software License. In summary, you may copy and distribute this book free of charge
|
||||
or for a profit. No explicit permission is required from the author for reproduction of this
|
||||
book in any medium, physical or electronic.</para>
|
||||
|
||||
<para>Derivative works and translations of this document must be placed under the Open Software License, and the original
|
||||
copyright notice must remain intact. If you have contributed new material to this book, you must make the material and
|
||||
source code available for your revisions. Please make revisions and updates available directly to the document
|
||||
maintainer, Peter Jay Salzman <email>p@dirac.org</email>. This will allow for the merging of updates and provide
|
||||
consistent revisions to the Linux community.</para>
|
||||
<para>Derivative works and translations of this document must be placed under the Open
|
||||
Software License, and the original copyright notice must remain intact. If you have
|
||||
contributed new material to this book, you must make the material and source code available
|
||||
for your revisions. Please make revisions and updates available directly to the document
|
||||
maintainer, Peter Jay Salzman <email>p@dirac.org</email>. This will allow for the merging of
|
||||
updates and provide consistent revisions to the Linux community.</para>
|
||||
|
||||
<para>If you publish or distribute this book commercially, donations, royalties, and/or printed copies are greatly
|
||||
appreciated by the author and the <ulink url="http://www.tldp.org">Linux Documentation Project</ulink> (LDP).
|
||||
Contributing in this way shows your support for free software and the LDP. If you have questions or comments, please
|
||||
contact the address above.</para>
|
||||
</legalnotice>
|
||||
<para>If you publish or distribute this book commercially, donations, royalties, and/or
|
||||
printed copies are greatly appreciated by the author and the <ulink
|
||||
url="http://www.tldp.org">Linux Documentation Project</ulink> (LDP). Contributing in this way
|
||||
shows your support for free software and the LDP. If you have questions or comments, please
|
||||
contact the address above.</para> </legalnotice>
|
||||
|
||||
</bookinfo>
|
||||
|
||||
|
@ -87,5 +91,5 @@
|
|||
|
||||
|
||||
<!--
|
||||
vim: tw=128
|
||||
vim: tw=100
|
||||
-->
|
||||
|
|
Loading…
Reference in New Issue