Archive for July, 2005

…As The Future Repeats Today

Tuesday, July 19th, 2005

- Good morning, how may I ruin your life today?
- How about messing with my ATA-drives like you did a month ago?
- Hang on to your suspenders, here we go!

hdb: dma_intr: status=0x51 { DriveReady SeekComplete Error }
hdb: dma_intr: error=0x84 { DriveStatusError BadCRC }
ide: failed opcode was: unknown
...
hdb: dma_intr: status=0x51 { DriveReady SeekComplete Error }
hdb: dma_intr: error=0x84 { DriveStatusError BadCRC }
ide: failed opcode was: unknown
ide0: reset: success
EXT3-fs error (device hdb1): ext3_free_blocks_sb: bit already cleared for block 2045422
Aborting journal on device hdb1.
ext3_abort called.
EXT3-fs error (device hdb1): ext3_journal_start_sb: Detected aborted journal
Remounting filesystem read-only
EXT3-fs error (device hdb1) in ext3_free_blocks_sb: Journal has aborted
...
EXT3-fs error (device hdb1) in ext3_free_blocks_sb: Journal has aborted
EXT3-fs error (device hdb1) in ext3_reserve_inode_write: Journal has aborted
EXT3-fs error (device hdb1) in ext3_truncate: Journal has aborted
EXT3-fs error (device hdb1) in ext3_reserve_inode_write: Journal has aborted
EXT3-fs error (device hdb1) in ext3_orphan_del: Journal has aborted
EXT3-fs error (device hdb1) in ext3_reserve_inode_write: Journal has aborted
__journal_remove_journal_head: freeing b_committed_data

As it seems I simply just cannot catch a break with ATA-drives recently. This scenario happened to my brand new Maxtor drive today, although I highly suspect the IDE-controller on the motherboard is the culprit in this case.
The partitions on the drive were suddenly remounted read-only by the kernel. After I rebooted my system parted wouldn’t even read the partition table and gpart appeared to hang while scanning the drive. I decided to upgrade my 2.6.11 kernel to 2.6.12 just in case it was a driver problem, although I very much doubted it as the motherboard has an Intel 801 controller which is a quite mature chipset. After the reboot I was presented with the kernel output shown above, strangely it would now read the partition table. Thanks to this I was able to run fsck on both the partitions on that drive (/home and /public), it did find a lot of problems but most of them were probably just created by files which had only been in part created when the read-only remount took place.
So far I haven’t found any corrupted files on the drive and I consider myself lucky. I’m going to spend the rest of the day burning DVDs. Luckily it’s raining outside so it’s not like my spirits were high to begin with.

My blogger<code />

Tuesday, July 19th, 2005

Emil posted his blogger code so I felt I had to have one too. ;)

My blogger code: B1 d++ t+ k+ s u– f- i o x e- l c– (decode it!)

++genkernel

Wednesday, July 6th, 2005

genkernel is a nice little Gentoo tool designed to make your everyday life with Gentoo as pleasurable as possible, especially if compiling the kernel is something that sends shivers down your spine. It works by taking the latest kernel source stored in /usr/src/linux, combine that with a specified kernel configuration file and compile a fully working kernel with the user not having to go through the tedious process of configuring Linux manually. Kernel configurations known to work are supplied with genkernel, but you can also specify your own configuration file if you wish to build a custom kernel.
So why am I blogging about genkernel when I’m not even a genkernel developer? For the simple reason that the imminent release of version 3.2.0 adds a long awaited feature, support for the Pegasos PowerPC platform!
If you are an eager beaver and want to try it out right away I suggest you edit /etc/portage/package.unmask, create it if it doesn’t already exist, and add “>sys-kernel/genkernel-3.1.9″ to unmask the 3.2.0-prereleases. Then emerge –ask –verbose ‘>=sys-kernel/genkernel-3.2.0_pre18′ in order to install the latest Pegasos-compatible genkernel. To build a kernel simply execute:

genkernel --genzimage --kernel-config=/usr/share/genkernel/ppc/Pegasos all

Whatever kernel /usr/src/linux points to will be compiled and installed into /boot as kernelz-<kernel version>, for instance, gentoo-sources-2.6.12-r4 will be called kernelz-2.6.12-gentoo-r4. In order to boot this kernel from SmartFirmware on the Pegasos, assuming /boot is on /dev/hda1 and your Gentoo root is on /dev/hda2 issue the following command:

boot hd:0 kernelz-2.6.12-gentoo-r4 root=/dev/ram0 init=/linuxrc real_root=/dev/hda2

If you have a Radeon you might want to append something like “video=radeonfb:800×600-16″ as well. Please note that genkernel will also install a yaboot-compatible kernel called kernel-genkernel-<kernel version> and an initramfs file called initramfs-genkernel-ppc-<kernel version>, you can safely remove these on the Pegasos since it does not support yaboot at this time.
I have tried genkernel with pegasos-sources-2.6.11-r5, gentoo-sources-2.6.12 and gentoo-sources-2.6.12-r4 and it produced working kernels for all of them. If however you run into any problems please report them to me.

A special thank you goes out to Tim Yamin (aka plasmaroo) for taking my genkernel-3.1.x patch and updating it to support 3.2.0 without me even asking him.

Power tools for power programmers

Tuesday, July 5th, 2005

Considering what I do for a living it’s high time that I blog about something appropriate for my “programming” category. Today I came upon an appropriate subject for just that purpose, a set of power tools any C++ programmer shouldn’t live without.

Today I read this article which was linked to via OSnews which explains how to use the serialization feature of the Boost C++ libraries. For those of you who didn’t already know it, serialization is the method of converting data into a binary string for storage on a hard drive or transmission over a network medium. In the world of distributed systems the process of serialization is frequently referred to as “marshalling”. This is one of the things CORBA will do for you in order to make your life easier, if you ever choose to use it.
I have not had a chance yet to use Boost’s serialization in one of my own projects. In fact, I didn’t know about it until I read the article mentioned above, so recently I wrote my own serialization routines which were far from being as clean as these are. I have however used Spirit, which is an “object-oriented recursive-descent parser generator framework”. Spirit integrates beautifully with C++ and gives an awesome Extended Backus-Normal Form-representation using nothing but standard ANSI C++ code. You have to see it to believe it.
So what are the advantages of using Boost’s serialization over writing your own routines? There are several advantages, for instance, it has seamless support for serializing STL containers. It is also very easy to use, especially if you are a C++ novice. But the biggest advantage of using Boost, at least in my opinion, is that it really increases readability of your code. The Boost classes that I have used took extremely good advantage of the powers of C++ in order to blend into your code in ways you didn’t think possible.

My advice is that if you haven’t tried Boost already give it a go. It contains powerful tools which will make your life much easier, it is peer-reviewed and comes with plenty of unit tests to maintain high quality and it integrates with your C++ code in a way you didn’t think possible (unless you are really skilled with templates in which case I salute you).