Porting LKL to Haiku's kernel API may not have been very hard, but convincing Haiku to load a properly built LKL-based add-on has presented some interesting and challenging problems.
The first milestone in this GSoC journey to building a generic file system driver based on Linux kernel code is booting LKL (Linux Kernel Library) inside Haiku.
For the short attention span: it works :)
...
KERN: KDiskDeviceManager::_AddDiskSystem() done: No error
KERN: file system: file_systems/iso9660/v1
KERN: KDiskDeviceManager::_AddDiskSystem(file_systems/iso9660/v1)
KERN: KDiskDeviceManager::_AddDiskSystem() done: No error
KERN: lklhaikufs: unhandled pheader type 0x4
KERN: file system: file_systems/lklhaikufs/v1
KERN: KDiskDeviceManager::_AddDiskSystem(file_systems/lklhaikufs/v1)
KERN: khaiku_env_timer:: LKL_TIMER_INIT
KERN: [lkl-console] Linux version 2.6.29 (gringo@lethe) (gcc version 4.4.4 (GCC) ) #10 Fri Jun 18 14:45:38 EEST 2010
KERN: [lkl-console] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256
KERN: [lkl-console] Kernel command line:
KERN: [lkl-console] lkl: IRQs initialized
KERN: [lkl-console] PID hash table entries: 256 (order: 8, 1024 bytes)
KERN: [lkl-console] lkl: timer initialized
KERN: [lkl-console] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
KERN: [lkl-console] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
KERN: [lkl-console] Memory available: 64900k/65536k RAM, (862k kernel code, 270k data)
KERN: [lkl-console] Mount-cache hash table entries: 512
KERN: [lkl-console] bio: create slab at 0
KERN: [lkl-console] io scheduler noop registered (default)
KERN: [lkl-console] lkl: syscall interface initialized
KERN: [lkl-console] console [lkl_console0] enabled
KERN: [lkl-console] Warning: unable to open an initial console.
KERN: [lkl-console] Switched to NOHz mode on CPU #0
KERN: [lkl-console] System halted.
KERN: khaiku_env_timer:: LKL_TIMER_SHUTDOWN
KERN: [lkl-console] lkl: IRQs freed
KERN: lkl: halt user callback called
KERN: KDiskDeviceManager::_AddDiskSystem() done: No error
KERN: file system: file_systems/nfs/v1
KERN: KDiskDeviceManager::_AddDiskSystem(file_systems/nfs/v1)
...
These are messages from /var/log/syslog that are generated when Haiku searches for available file system add-ons. One of those drivers is my lklhaikufs driver. Messages with [lkl-console] are from LKL (similar to what you see when a normal Linux kernel boots) :)
Haiku has great support for its own file system, but most others are only available read-only or not accessible. Providing reliable read-write support to one such file system is a complex task, and needs to be repeated for each type of file system.
Linux contains state of the art, full featured implementations for a large number of file systems.
lkl-haiku-fsd is a generic driver based on the Linux kernel library (LKL), reusing Linux' optimized and debugged file system implementations.