Finished “Linux Kernel Development” by Robert Love

One of the great things about working at VMware is that they have a shuttle that takes me from a light rail station 10 minutes from my house to work. Aside from savings lots of money on gas, this gives me a good chunk of time to read.

I just finished reading “Linux Kernel Development” by Robert Love and I have to say that I really enjoyed it. I liked the earlier chapters a bit better than the later ones – I’m not sure if this is the subject matter or that the author got tired and less specific in the later chapters or I got tired of reading about kernel internals. Maybe it’s just me but it seemed that chapters 1 through 11 were more lucid than chapters 12 through 20.

In any case, I found the book to be excellent and remarkably clear for a detailed topic such as the Linux kernel.

Here’s the table of contents, in case you’re interested in what it covers:


Foreword, by Andrew Morton
Preface
Chapter 01: Introduction to the Linux Kernel
Chapter 02: Getting Started with the Kernel
Chapter 03: Process Management
Chapter 04: Process Scheduling
Chapter 05: System Calls
Chapter 06: Interrupts and Interrupt Handlers
Chapter 07: Bottom Halves and Deferring Work
Chapter 08: Kernel Synchronization Introduction
Chapter 09: Kernel Synchronization Methods
Chapter 10: Timers and Time Management
Chapter 11: Memory Management
Chapter 12: The Virtual Filesystem
Chapter 13: The Block I/O Layer
Chapter 14: The Process Address Space
Chapter 15: The Page Cache and Page Writeback
Chapter 16: Modules
Chapter 17: kobjects and sysfs
Chapter 18: Debugging
Chapter 19: Portability
Chapter 20: Patches, Hacking, and the Community
Appendix A: Linked Lists
Appendix B: Kernel Random Number Generator
Appendix C: Algorithmic Complexity
Bibliography
Index

A work in progress, I’m jotting down some notes (little more than a lightly-annotated table of contents) about the book to help me jog my memory later.

I’m now looking forward to Robert’s new  soon-to-be-released book: Linux System Programming: Talking Directly to the Kernel and C Library

Book cover

inkblot: GNOME ink level utility

I’ve posted recently (here and here) about libinklevel and mentioned the simple command-line client, simply called “ink“.

For the graphically-inclined, there’s a pretty nice GNOME app called “inkblot” that an put a status icon in your tray and you can click it to get more detailed information.

inkblot

My printer has 6 ink cartridges, but inkblot only shows levels for the cyan, magenta, and yellow. Presumably it is rolling cyan/photo cyan and magenta/light magenta into one number and it seems to be doing this by taking the lesser number in each pair.

Getting access to the printer device without sudo

Having recently discovered libinklevel and ink, I’ve been using them to check the status of the ink levels on my Canon i950 printer, connected via USB to my Ubuntu Feisty Fawn box. I’ve been having to run the ink command using sudo so that libinklevel can access the raw device, /dev/usblp0. E.g.:

$ sudo ink -p usb

It’s tedious and easy to forget the sudo though.

Let’s have a look at the permissions on /dev/usblp0:

$ ls -l /dev/usblp0 
crw-rw---- 1 root lp 180, 0 Jul 18 06:03 /dev/usblp0

A ha. Users in the lp group can access the device. Let me add myself to the lp group then:

$ sudo -G lp -a marc
(Log out and back in so that my user picks up the new group - 
You can verify that you're in the group with the id command)
$ ink -p usb  
ink v0.4.1 © 2007 Markus Heinz

Canon i950

Cyan:                          40%
Light Cyan:                   100%
Black:                         10%
Yellow:                        70%
Magenta:                       10%
Light Magenta:                100%

Voila!

Patch to make libinklevel work with a Canon i950 printer

This weekend, while cruising freshmeat.net, I happened upon libinklevel, from Markus Heinz. From the description:

Libinklevel is a library for checking the ink level of your printer on a system which runs Linux. It supports printers attached via parallel port or usb.

I downloaded and installed the latest versions of that and a complementary command-line tool called ink (uses libinklevel and is from the same author). No luck with my Canon i950 printer:

marc@tbird:~/sw/libinklevel-0.7.2$ sudo ink -p usb
ink v0.4.1 © 2007 Markus Heinz

Printer not supported.
Could not get ink level.

After a few minutes of glancing at the code, I was able to get it working. Here’s the patch. Now the output of the ink tool looks like this:

marc@tbird:~/sw/libinklevel-0.7.2$ sudo ink -p usb
ink v0.4.1 © 2007 Markus Heinz

Canon i950

Cyan:                          40%
Light Cyan:                   100%
Black:                         10%
Yellow:                        70%
Magenta:                       10%
Light Magenta:                100%

While I was modifying the code, I noticed that there was a #define constant called MAX\_NUMBER\_OF\_MODELS, that needed to be updated whenever one adds or removes printers to the existingPrinters array. This was a little cumbersome, so I modified the code to not need that. Here’s the patch.

I will of course send these patches to the author, Markus Heinz, so that the Canon i950 can work “out of the box” with the next version of libinklevel.

Ubuntu: Fixing NO_PUBKEY CC919A31E23C5FC3 error from Automatix repository

Recently, my apt-get updates started failing with:

W: GPG error: http://www.getautomatix.com edgy Release: 
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY CC919A31E23C5FC3
W: You may want to run apt-get update to correct these problems

This was easily fixed with:

$ gpg --keyserver subkeys.pgp.net --recv CC919A31E23C5FC3
gpg: requesting key E23C5FC3 from hkp server subkeys.pgp.net
gpg: key E23C5FC3: public key "Arnav Ghosh (Automatix Team Lead) " imported
gpg: Total number processed: 1
gpg:               imported: 1
$ gpg --export --armor E23C5FC3 | sudo apt-key add -
OK

Now, apt knows about the gpg public key for Automatix and doesn’t complain when I do sudo apt-get update.