knewbies project? - updating LDD3 source
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel. http://lwn.net/Kernel/LDD3/ http://examples.oreilly.com/9780596005900/ Neither the OReilly tarball, nor the googlecode's svn repo will compile for me on an updated F-14 box, neither against uname -r, or a local git-tree. So I pulled the svn-tree, and made these changes. I got a fair way to getting things to compile. Changes are quick-n-dirty, and some may be wrong, esp around workqueue stuff - I pretty much did what compiler told me, w/o any analysis. I didnt even get compilation on the aio/iovec users, on the changes from 2003. I havent really gotten my head around the whole conversion strategy; I know a loop over iovec elements is probably needed, but Im unclear where it should be. and Im unsure whether these functions are now cluttering up things. static void sculld_do_deferred_op(void *p) static int sculld_defer_op(int write, struct kiocb *iocb, const struct iovec *iov, size_t count, loff_t pos) I guess the point is Ive run out of time now, and am hoping for a dose of clarity, and further patches, to get LDD3 source compiling, up-to-date, and reflecting current best practices. GRUMBLING: its annoying that the googlecode web-page obfuscates the site owner, making it impossible to reach him. Username: guanzhi1...@gmail.com Is there another LDD3 repo somewhere, that a google search didnt reveal to me ? perhaps on kernel.org ?? Should there be ? Im attaching my svndiff, in hte hopes that folks here will apply it and improve upon it. thanks ~jimc
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
http://lwn.net/Kernel/LDD3/ http://examples.oreilly.com/9780596005900/
the one caution i would give here is that quite a bit of code in LDD3 shouldn't be updated, anyway, since it reflects features that have been deprecated for quite some time. for instance, no one should be writing proc files anymore. also, ioctl()s are also discouraged for the most part. so i would be selective about what parts of LDD3 code *should* be updated as examples of good kernel programming. rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ========================================================================
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
http://lwn.net/Kernel/LDD3/ http://examples.oreilly.com/9780596005900/
the one caution i would give here is that quite a bit of code in LDD3 shouldn't be updated, anyway, since it reflects features that have been deprecated for quite some time.
for instance, no one should be writing proc files anymore. also, ioctl()s are also discouraged for the most part. so i would be selective about what parts of LDD3 code *should* be updated as examples of good kernel programming.
rday
There is a repo on GitHub with the same purpose. I haven't checked it out personally, but it's probably worth a look. https://github.com/martinezjavier/ldd3
On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
http://lwn.net/Kernel/LDD3/ http://examples.oreilly.com/9780596005900/
the one caution i would give here is that quite a bit of code in LDD3 shouldn't be updated, anyway, since it reflects features that have been deprecated for quite some time.
for instance, no one should be writing proc files anymore. also, ioctl()s are also discouraged for the most part. so i would be selective about what parts of LDD3 code *should* be updated as examples of good kernel programming.
rday
Robert is right, the drivers are quite old. As Robert says proc files are deprecated in favor of sysfs and ioctl are discouraged in favor of netlink sockets. Another example is that most LDD3 driver modules are loaded with a script that create the device nodes. Unless your system is a embedded device (an even in that case) you should let udev do this). So instead of having drivers that just compile cleanly and works, it would be better to update the APIs the drivers use and how they interact with userspace.
There is a repo on GitHub with the same purpose. I haven't checked it out personally, but it's probably worth a look.
As the author of the repo I can tell that the drivers compile with kernels 2.6.32, 2.6.35 and from 2.6.37 forward (including 2.6.39 and linux-next). I create it for academic purposes, I haven't thest all the drivers, only the ones I needed for the students. Best regards, -- Javier Martínez Canillas (+34) 682 39 81 69 PhD Student in High Performance Computing Computer Architecture and Operating System Department (CAOS) Universitat Autònoma de Barcelona Barcelona, Spain
On Tue, 24 May 2011, Javier Martinez Canillas wrote:
On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
http://lwn.net/Kernel/LDD3/ http://examples.oreilly.com/9780596005900/
the one caution i would give here is that quite a bit of code in LDD3 shouldn't be updated, anyway, since it reflects features that have been deprecated for quite some time.
for instance, no one should be writing proc files anymore. also, ioctl()s are also discouraged for the most part. so i would be selective about what parts of LDD3 code *should* be updated as examples of good kernel programming.
rday
Robert is right, the drivers are quite old. As Robert says proc files are deprecated in favor of sysfs and ioctl are discouraged in favor of netlink sockets. Another example is that most LDD3 driver modules are loaded with a script that create the device nodes. Unless your system is a embedded device (an even in that case) you should let udev do this). So instead of having drivers that just compile cleanly and works, it would be better to update the APIs the drivers use and how they interact with userspace.
there are also other drivers that simplify things immensely for you that aren't mentioned in LDD3, such as the "misc" character driver, that lets you register a character driver that needs only one minor number at major number 10 and some randomly chosen and available minor number. you can then get the minor number from the file /proc/misc but you don't need to as the /dev file is (as far as i understand it) created for you automatically. in other words, you can avoid a lot of the work involved in writing a character driver if you take advantage of that misc driver. rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ========================================================================
Hello all, On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Javier Martinez Canillas wrote:
On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
Why not take this a little bit higher and rewrite the LDD3 book sections that need updating, not (only) the source code examples. This can be taken on piecewise. I would see this identical to kernel/Documentation/* except that the pieces are targetting device driver developers. Regards, -- Leon
On Tue, 24 May 2011, Leon Woestenberg wrote:
Hello all,
On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Javier Martinez Canillas wrote:
On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
Why not take this a little bit higher and rewrite the LDD3 book sections that need updating, not (only) the source code examples.
This can be taken on piecewise.
I would see this identical to kernel/Documentation/* except that the pieces are targetting device driver developers.
i would take a closer look at the samples/ directory in the kernel source tree. i am, in fact, writing a number of sample modules and drivers to be incorporated into an introductory kernel programming and device drivers course but i don't think i can share them all as they're part of the official courseware. but i'm sure there are plenty of people who can write sample modules and drivers that would fit nicely in that samples/ directory. rday -- ======================================================================== Robert P. J. Day Ottawa, Ontario, CANADA http://crashcourse.ca Twitter: http://twitter.com/rpjday LinkedIn: http://ca.linkedin.com/in/rpjday ========================================================================
i would take a closer look at the samples/ directory in the kernel source tree. i am, in fact, writing a number of sample modules and drivers to be incorporated into an introductory kernel programming and device drivers course but i don't think i can share them all as they're part of the official courseware. but i'm sure there are plenty of people who can write sample modules and drivers that would fit nicely in that samples/ directory.
rday
The samples/ directory would be an excellent place to add examples because the code would have to be maintained. Does anyone know what is the policy to make a sample worth its place in samples dir an not be considered as a bloat? Looking at the dir seems to be that is only for samples about the usage of internal kernel API (kfifo, kprobes, kobject, etc). Regards, -- Javier Martínez Canillas (+34) 682 39 81 69 PhD Student in High Performance Computing Computer Architecture and Operating System Department (CAOS) Universitat Autònoma de Barcelona Barcelona, Spain
I would see this identical to kernel/Documentation/* except that the pieces are targetting device driver developers.
Take a look at the smallsample at the link below. The examples are well documented and it could be expanded to include more features of the kernel. http://gnudd.com/workdoc.shtml -- /manohar
On Wed, May 25, 2011 at 2:02 AM, Leon Woestenberg <leon.woestenberg@gmail.com> wrote:
Hello all,
On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Javier Martinez Canillas wrote:
On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
On Tue, 24 May 2011, Jim Cromie wrote:
over at http://code.google.com/p/ldd3/ it says: The famous "Linux Device Drivers" released the sample code. but the code does not reflect the latest kernel updates, some of code cannot even compile. This project is to make it compatible with the current kernel.
Why not take this a little bit higher and rewrite the LDD3 book sections that need updating, not (only) the source code examples.
This sounds like an excellent idea. Can a project like that could be started in sourceforge ?? Can somebody take the ownership for the same ?? I am sure a lot of us would like to contribute. -- Naren
This can be taken on piecewise.
I would see this identical to kernel/Documentation/* except that the pieces are targetting device driver developers.
Regards, -- Leon
On Wednesday 25 May 2011 09:12 AM, naren.mehra@gmail.com wrote:
Why not take this a little bit higher and rewrite the LDD3 book
sections that need updating, not (only) the source code examples.
This sounds like an excellent idea. Can a project like that could be started in sourceforge ?? Can somebody take the ownership for the same ?? I am sure a lot of us would like to contribute. Small suggestion. If the book is rewritten again it will be outdated in some time. instead setup a wiki and every one contributes/changes to keep it update.
Already kernelnewbies.org is setup using wiki and it is up and running always, so this website can can be reused instead of creating a new one. - Mohamed Thalib H.
On Wed, May 25, 2011 at 11:57 AM, Mohamed Thalib H <hmthalib@gmail.com>wrote:
On Wednesday 25 May 2011 09:12 AM, naren.mehra@gmail.com wrote:
Why not take this a little bit higher and rewrite the LDD3 book
sections that need updating, not (only) the source code examples.
This sounds like an excellent idea. Can a project like that could be started in sourceforge ?? Can somebody take the ownership for the same ?? I am sure a lot of us would like to contribute. Small suggestion. If the book is rewritten again it will be outdated in some time. instead setup a wiki and every one contributes/changes to keep it update.
Already kernelnewbies.org is setup using wiki and it is up and running always, so this website can can be reused instead of creating a new one.
This is really good suggestion to use the wiki and update the info as time goes. Regards, Sumeet
participants (9)
-
DG -
Javier Martinez Canillas -
Jim Cromie -
Leon Woestenberg -
Manohar Vanga -
Mohamed Thalib H -
naren.mehra@gmail.com -
Robert P. J. Day -
sumeet linux