• iBook and the clamshell mode

    A reader named Richard saw some of my old posts and seems to be confused about how I got the iBook G4 I own (one of the latest available models) to work in clamshell mode. The thing is that I didn't get it to work as expected.After buying the BenQ FW202P flat panel I replaced my old PS/2 keyboard and mouse with USB peripherals, hoping that they'd let me use my iBook in clamshell mode. Of course, I had to apply the Screen Spanning Doctor hack, which allows me to use a desktop that spans over the external flat panel (not in cloning mode). Note that extending the desktop works perfectly at a resolution of 1680x1050, albeit some effects are a bit slow (e.g. Exposé).Unfortunately, the "unofficial" clamshell mode enabled by SSD does not work properly with this specific iBook G4 model. No matter what I try, the external monitor always gets an incorrect, non-native resolution that is either cropped or expanded in ugly ways. But, as I had already bought the other peripherals (and I do not regret it, because they are much better than the previous ones), I did the following: I connected the external monitor, mouse and keyboard and powered up the iBook regularly. When it got to the login screen, I turned the internal screen's brightness to its minimum so that it didn't consume more power than really needed.As regards the desktop setup, I stuck the internal monitor to the right of the external one and vertically centered it; this way I'd use the hot corner functionalities in the latter. I also moved the menu bar to the external one, making it the primary monitor. This setup works fairly well and "simulates" a real clamshell mode.However, I'm not using this setup any more because it's not very comfortable. First of all, it's quite annoying to have to connect/disconnect everything over and over again (which is a mess on the table) and the image in the flatpanell appears somewhat blurry due to the regular D-Sub connection (it worked fine with a CRT monitor). I guess things could be much better if I had a KVM... And secondly, every time you switch between the external and internal monitor, you "lose" your settings. For example, your preferred applications do not appear where you left them, your terminal settings (font size, etc.) are not appropriate both monitors, and a bunch of other little details that make this setup a bit uncomfortable. [Continue reading]

  • iParty 8 slides available

    I've given my NetBSD talk today at the iParty 8. The slides are now available in the advertisement material section of the NetBSD web site; note that they are in Spanish. If the talk video record is made public, I'll publish a link. Enjoy! [Continue reading]

  • NetBSD's KNF: Prefixes for struct members

    The NetBSD coding style guide, also known as Kernel Normal Form (KNF), suggests to prefix a struct's members with a string that represents the structure they belong to. For example: all struct tmpfs_node members are prefixed by tn_ and all struct wsdisplay_softc members start with sc_. But why there is such a rule? After all, the style guide does not mention the reasons behind this.The first reason is clarity. When accessing a structure instance, whose name may be anything, seeing a known prefix in the attribute helps in determining the variable's type. For example, if I see foo->sc_flags, I know that foo is an instance of some softc structure. As happens with all clarity guidelines, this is subjective.But there is another reason, which is not more technical. Using unprefixed names pollutes the global namespace, a specially dangerous situation if the structure belongs to a public header. Why? Because of the preprocessor — that thing that should have never existed — or more specifically, the macros provided by it.Let's see an example: consider a foo.h file that does this:#ifndef _FOO_H_#define _FOO_H_struct foo { int locked;};#endifAnd now take the following innocent piece of code:#define locked 1#include <foo.h>Any attempt to access struct foo's locked member will fail later on because of the macro definition. Prefixing the variable mitigates this situation. [Continue reading]

  • NetBSD talk at iParty 8

    I've been invited to give a talk about NetBSD on Saturday 22nd at the eighth iParty. iParty is a set of FOSS-related activities hold at Castellón de la Plana, Spain, which includes conferences, workshops and competitions.I'll start with an general introduction to NetBSD to later focus on development issues: how to contribute to the project and what needs to be done; I expect it to be somewhat technical. The reason behind this choice is that Google is preparing the Summer of Code 2006 and it would be really nice to have more students than past year working for NetBSD. The more students available, the higher chance NetBSD gets more work done! [Continue reading]

  • tmpfs on FreeBSD

    It has just been brought to my attention that tmpfs is being ported to FreeBSD by Rohit Jalan. These are good news: more eyes looking at the code (even if it has been modified to work on another OS) means that more bugs can be catched. [Continue reading]

  • NetBSD/i386 development under OS X

    Mac OS X is the only operating system in my iBook and I have no plans to change this in the near future (installing NetBSD was frustrating and I do not want Linux). However, I want to be able to do NetBSD development on it shall the need arise. And it has to be easy.My idea was to have a disk image with NetBSD/i386 on it and to be able to mount it from OS X to manage its contents (e.g. to update its kernel or to install new userland). Therefore, installing on a Apple UFS file system was a must. NetBSD can read such file systems but unfortunately it cannot boot from them (as far as I know); hence the need for a little boot FAT partition (see below).As a result I have got a NetBSD/i386 installation under Q, completely manageable from OS X. The overall setup renders a very nice development environment.Let's see how (not exactly trivial):Get NetBSD sources on your OS X machine.Build a cross-compiler toolchain for i386, which basically means ./build.sh -m i386 tools. Doesn't build.sh rock?Prepare a custom i386 kernel configuration and build it. You can simply get GENERIC, but you must enable options APPLE_UFS as well as options FFS_EI (thanks to Rudi Ludwig for pointing the latter out). Do not disable file-system MSDOS.Create a new PC under Q and specify a new 512MB raw disk image (qcow will not work).Use the command line fdisk utility to partition the new image: create a 50MB FAT16 partition (type 6) and leave the rest for Apple UFS (type 168). You may have geometry problems here as fdisk will think that the disk is extremely large; for the 512MB disk we just created, use 1040 cylinders, 16 heads and 63 sectors per track (you can give this to fdisk as parameters).The disk created by Q is stored in ~/Documents/QEMU/pcname.qvm/Harddisk_1.raw; I will refer to it as disk.img for simplicity. Tell OS X to attach it: hdiutil attach -nomount disk.img.Format the new partitions. WARNING: OS X attaches this as disk1 for me; check the device name in your machine before proceeding and adjust it accordingly. Simply do: newfs_msdos /dev/disk1s1 and newfs /dev/disk1s2.Detach the image and reattach it, but this time let OS X mount the file systems within them: hdiutil detach disk1 ; hdiutil attach disk.img.Use the finder to rename the partitions to more representative names. E.g. NB-Boot and NB-Root.Now it's time to install NetBSD under the new disk. We need to do this manually. Assume that all of the following commands are run from within /Volumes/NB-Root:Unpack the NetBSD sets by doing: for f in ~/NetBSD/i386/binary/sets/[bcegmt]*.tgz; do sudo tar xzpf $f; done.Create the device files in dev by executing the following: cd dev && sudo ./MAKEDEV -m ${TOOLDIR}/bin/nbmknod all. TOOLDIR points to the directory holding the cross tools you built before.Create a minimal etc/fstab. E.g.:/dev/wd0f / ffs rw 1 2/dev/wd0e /boot msdos ro,-l 0 0Create the boot directory. This clashes with the standard /boot file in a NetBSD system, but we will not have this one; feel free to use a different name.Edit etc/gettytab and add al=root to the default entry. This will automatically log into root's session, so we do not need to set a password for it.Edit rc.conf and set rc_configured=YES. Disable all the services you will not use for better boot up speed: cron=NO inetd=NO sendmail=NO virecover=NO wscons=YES. Do not forget to set the host name: hostname=devel.Edit wscons.conf and disable all extra screens.Create links that will point to the kernels: ln -s boot/netbsd boot and ln -s boot/netbsd.gdb. This is the reason why my boot partition is 50MB; the debugging kernels take a lot of space.At last, we need to install the boot loader in the FAT partition. I've chosen GRUB so I needed a GRUB boot floppy (an image) at hand to finish the setup.Mount the GRUB image and copy its files to the boot partition. E.g.: cp -rf /Volumes/GRUB/boot /Volumes/NB-Boot. You need the fat_stage1_5 file for this to work.Create a minimal /Volumes/GRUB/boot/grub/menu.lst file for automatic booting:default 0timeout 5title NetBSD - Development kernelkernel (hd0,0)/netbsd root=wd0fCopy the kernel you built at the beginning to /Volumes/GRUB/netbsd.Detach all the disk images: hdiutil detach disk1 and hdiutil detach disk2.Configure your virtual PC in Q to boot from this GRUB floppy disk image and embed GRUB into your virtual hard disk: root (hd0,0) and setup (hd0).Change Q's configuration to boot straight from the hard disk image.And at last... Boot NetBSD!With this setup you can mount your development image with hdiutil attach disk.img, mess as you want with its contents, detach it and relaunch your Q session. Pretty neat :-) [Continue reading]

  • Apple's customer service

    Two months ago I bought an Apple USB Keyboard directly from my nearest Apple Center, MicroGestió. Unfortunately, the Enter key started to behave incorrectly some days ago; its movement wasn't as smooth as that of other keys and in some cases it simply didn't move. For example, it was really hard to press it when pushed from the up or left sides.In my case, I've noticed that I tend to press the Enter key towards the top, with the force going "upwards". This made it fail many times, requiring me to hit it again, harder and in the middle. Very annoying.So... I went to the store this morning to ask if this was covered by the warranty; I had nothing to lose. And yes it was; they replaced the entire keyboard with a shiny new one without questions. Great!Of course, I'm talking about this specific Apple Center. I do not know about the customer service in the others, but there surely are better and worse ones. (Would like to be proved wrong ;-) [Continue reading]

  • Mac OS X: Boot Camp

    Apple has just published Boot Camp, a utility to install Windows XP on a Mac. As I understand it, this provides an EFI module for legacy BIOS compatibility, a set of Windows drivers for the Apple hardware and the required tools to ease Windows' installation.In other words: it lets you to flawlessly install Windows XP SP2 (be it the Home or Professional edition) in one of the new Intel-based Macs. Beta versions are now available for downloaded and the final version will be included in Mac OS X 10.5 Leopard.Great, Apple. I do not have an excuse any more to not replace my desktop machine with a Macintosh. In fact, I'm dying to switch but I'll resist for some more time ;-)Edit (April 7th, 20:57): Dirk Olbertz has installed Ubuntu on his iMac using Boot Camp (the link is in German). So this seems not to be restricted to Windows. [Continue reading]

  • GNOME 2.14.0 hits pkgsrc

    After three weeks of intense work, I am pleased to announce that GNOME 2.14 is now available in pkgsrc, the NetBSD Packages Collection.As happens with all other major GNOME releases, this one provides a set of polishments, cleanups and several new features over the 2.12 series. You can find more information in the official release page (linked above).I am happy to say that this release works fairly well under NetBSD. There are still some rough edges (that is, programs that crash on startup or do not work as expected) but there shouldn't be much regressions from the previous version. I think I will prepare a list of known broken stuff in case people wants to help because fixing everything requires a lot of manpower.To give you some approximate numbers, the process consisted of 80 package updates, 8 new packages and 16 revisions of the new and updated packages. Some more may come in the following days.As usual, updating from older versions is not exactly easy using pkgsrc. I suggest you to either build the whole new release in a sandbox using pkg_comp or zap all your installed packages to reinstall from scratch.How to install it? Just use the meta-pkgs/gnome package to install everything that is part of the official GNOME distribution or choose meta-pkgs/gnome-base if all you want is a minimal desktop.Please report any problems you find using send-pr(1).You can also check out the official announcement. Have fun! [Continue reading]