Tuesday, October 31, 2006

Piloting Blind, Chapter 1

So I've been trying to get my Palm (more specifically, the original Handspring Visor) to work with my PC-BSD machine. I installed JPilot, which seems to be a very nice freeware Palm desktop program. I was even able to import my Windows Palm desktop settings into it, and it looks pretty solid. I need to look into the alarms a little more, as I don't really want an 11mb program hanging around just to remind me to pick up my daughters even now and then. But still, that step went pretty smoothly. And if I was real good about it, I would make a PBI.



The next step was to get it to send the data down to my Palm, via its USB connection. This was a whole new ballgame. Of course, just plugging it in and hitting the HotSync button didn't work. Nor did clicking on the sync button on JPilot, as it couldn't open the device. It was looking for /dev/pilot, and it wasn't there. So I needed more details.



This lead me into the netherworld of /etc/devfs.conf (for setting up devices at boot time), /etc/devfs.rules (for setting up devices at runtime), /etc/usb.conf (for setting up actions when USB devices get connected), and /etc/devd.conf (actions on kernel events like attach and detach). Phew - so many ways to do a simple task!



Despite some great help on the FreeBSD.questions list (special shout-outs to both Anish and Damien for their patience), I still can't get it to quite work. At first, the Visor would just time out and not notice anything had tried to access it. After more struggles, I would at least get the reassuring 'beep beep' from the cradle that said something was coming across, but still no joy. Now, I can get it to download data from the Visor, but I can't seem to upload it. Here's what I did to get this far.



Syncing with a Pilot on FreeBSD seems to boil down to one of two methods - either pilot-sync or coldsync. JPilot uses the pilot-sync method, so that's the one I concentrated on. Unfortunately, it seems to be the less supported one in the FreeBSD community, so it meant more work. There's a couple of different pages on the pilot-link web site that try to explain how to do this, but in typical fashion, they either don't apply directly to my setup or are incomplete and/or out of date. The README.usb has a FreeBSD section, which talks about how to modify the usbd.conf file. Oddly enough, the author of that section, Anish, replied to me as follows on the questions mailing list:




First you shouldn't be using usbd.conf. You should be using devd.conf and devfs.rules.

Disable usbd.

Add to devd.conf:
attach 0 {
device-name "ugen[0-9]+";
match "vendor" "0x082d";
match "product" "0x0100";
match "release" "0x0100";
action "/usr/local/sbin/pilot-sync-ugen.sh $device-name";
};

Setup devfs.rules if you have yet to do it:
http://am-productions.biz/docs/devfs.rules.php

Add your user to the operator group or change the mode to 0666 below.
Add to devfs.rules:
add path 'ugen*' group operator
add path 'ugen*' mode 0660

In /usr/local/sbin/pilot-sync-ugen.sh:
#!/bin/sh
#
JPILOT=/usr/X11R6/bin/jpilot-sync
JPILOT_USER=your_username_here
export JPILOT_HOME=/home/$JPILOT_USER
PILOTPORT=usb:/dev/$1
COMMAND=`echo $JPILOT -p $PILOTPORT -b`
# run command ie. (sync)
/usr/bin/su $JPILOT_USER -c "$COMMAND"


Woo boy, a lot of info to digest here! First, he now says to not use usbd and its associated usbd.conf file, and instead use devd.conf. Seems like they both do the same thing, but usbd.conf works only for USB files, while devd.conf works for any run-time devices, like an Ethernet pc-card. I guess maybe the devd.conf is a newer and more generalzied way of dealing with devices, as I'm not sure why to choose one over the other. Here's what I think the lines from Anish means for the /etc/devd.conf lines:



attach 0 {

There's really two basic "actions" you can match in the devd.conf file - attach and detach. The number lets you prioritize the actions, so "attach 0" would happen before "attach 10".



device-name "ugen[0-9]+";

This runs a regexp against the device name being added or removed. If it doesn't match, then the block of statements is ignored. So we're looking for an action on a device called "ugen0" through "ugen9". Which, as the man page for ugen tells us, is a "generic USB" device, and only shows up when you hit the HotSync button on the Palm, something that took a bit to figure out.



match "vendor" "0x082d";

match "product" "0x0100";

match "release" "0x0100";


Now we're doing more matching, because we can't do this on just any ole generic USB device. So we'll check the reported vendor, product and release IDs to see if it matches. These are some magical numbers and, unfortunately, are hard to discover. These ones in particular work for a Visor, but are probably different for all other Palm devices. The easiest way I found to track down these numbers is to run the USB daemon from the command line with the debug option on, and see what it reports:




# killall usbd

# usbd -d -v -v

[bunch o' messages]

[hit the HotSync button]

device-attach event at 1162391812.483582000, Handspring Visor, Handspring Inc:

vndr=0x082d prdct=0x0100 rlse=0x0100 clss=0x0000 subclss=0x0000 prtcl=0x0000

^C


You can see the values listed when the device gets attached. Plug these in for your Palm device.



action "/usr/local/sbin/pilot-sync-ugen.sh $device-name";

};


Now, if all the matches actually are true, we can finally do an action. Here, Anish says to run the shell script we're going to create later and pass it the $device-name, which is a variable that gets set to the match device path (I actually found that documented somewhere, but can't find it at the moment!).



Well, that's a long enough post for now! Suffice to say, we've only just begun our journey of run-time devices, and I still haven't found Palm nirvana yet.




Friday, October 27, 2006

Get Real

A book from the good folks at 37Signals has just been made available for free on the web. Called Getting Real, it's a primer on how to publish a great web app. Looks like some good reading!



Getting Real: What is Getting Real? (by 37signals)



Thursday, October 26, 2006

That PC-BSD tango

Just came across a pretty cool web site called "BSDTalk". Twice weekly, a "podcast" dealing with the BSD world is posted. Some pretty interesting stuff. By the way, you click on the title of the entry to download the MP3 for the podcast. I didn't make that connection at first.



There have been a couple of interesting interviews dealing with PC-BSD. First up is a talk with Kris Moore, the force behind PC-BSD. The interview ranges widely, from how the iXsystems purchase will afftect PC-BSD, to what makes it good and where it will be going in the future. Solid talk all around.



bsdtalk078 - Kris Moore from PC-BSD



Next up is an interviewb with Matt Olander from iXsystems, again covering the PC-BSD "acquisition" and other iXsystems stuff:



bsdtalk077 - Matt Olander from iXsystems



Dru Lavigne gives a quick overview of the latest PC-BSD 1.3 beta, which looks really nice, although it has problems installing on my trailing edge test box:



Review of PC-BSD 1.3 beta



She also has interviews Kris & Matt:



Why iXsystems Bought PC-BSD



Wednesday, October 25, 2006

Stupid Shell Tricks

Funny page about "Useless" shell tricks, that are much better done in other ways. Can't say as I'm entirely innocent of a few of them myself....



Useless Use of Cat Award



Tuesday, October 24, 2006

conf those ports

Yet another port having to do with ports. I'm still confused as to which port builder is "better", and here's a port that claims to work with all three "major" port bulders, in order to set up the correct port options. I often need this, as I usually build from within an Emacs shell, and this go a kaflooey if the port tries to put up an options dialog. So I'd like to set all the options first, then invoke it with BATCH mode so it doesn't prompt me again. Maybe I'll look at this.



Port description for sysutils/portconf



Sunday, October 22, 2006

Partition Man

Jerry McAllister (jerrymc at msu dot edu), a prolific poster on the FreeBSD questions list, wrote an impressive response to some questions about how to parition a hard drive for a shared WinXP / FreeBSD install. I thought it was too good to just pass away into the torrent that is freebsd.questions, so I asked for and got permission to reprint it here. Pay particular attention to his careful description of partitions vs. slices.






> The only thing that keeps me back is the installation: I got a
> almost 10 (even not more) manuals about FreeBSD and none, absolutely
> none, does not specify the very common possibility of having a disk
> already with 2 partitions in Windows, not to mention even further
> possibilities as having 2 disks, from which one having 2 partitions.


I guess this is what I do not understand. Most books on FreeBSD that I have seen, including the FreeBSD handbook (available online at the FreeBSD website and is essential reading) have two possibilities. The first is installing on a disk that is completely given to FreeBSD and the second is dividing the disk between Some other OS (usually MS-Win of some flavor) and FreeBSD. None that I have seen say two partitions in Windows being required (just allowed if desired).



> For instance I have 2 computers, each with 2 SATA disks: on the first, the
> master, Windows 2000 or XP, and on the other, on the first partition, the
> other Windows flavor, respectively XP and 2000, the second partition, in
> both cases, being left for data. Both systems are in dual boot; I decided
> to have ready (and use) both Windows flavors after a couple of very bad
> experiences of crashings; thus, in case of crush, at least on of the 2 OS
> would be still working allowing me to access the data.


Well, you have to make room for FreeBSD somewhere. FreeBSD does not run from a Windows slice. It requires its own slice. Note, the term "slice" which generally corresponds to what the MS-Win world calls a "primary partition" BSD Unix uses the term 'partition' to refer to a subdivision of a slice. That can at first be confusing, because sometimes people forget and use both terms interchangeably and they are definitely not the same thing.



Just a little summary:



In the MS and also the BSD world a disk can be divided in to four primary divisions which in the BSD world are called slices. In each world there are ways of further dividing the slices in to sub-units. In the BSD world those are called partitions. In the MS world, they have something called extended partitions, (but they are not the same).



You need to have at least one slice (primary partition is MS speak) to install FreeBSD. That slice will be designated as a FreeBSD type and MS-Win will no longer be able to talk to it. Although FreeBSD, which is smarter, will be able to talk to most of the other MS-Win slices. (I don't know if it can talk to an extended partition yet or not)



That FreeBSD slice can be all of a disk or just part of it and be one of the primary slices which are number 1..4. If a single disk has more than one OS, and one of those is some MS-Win thing, then it is normally better to leave the MS-Win stuff as first on the disk. FreeBSD doesn't care, but MS-Win might screw up otherwise. If you are going to use a whole disk for FreeBSD, then it doesn't matter.



> Now I decided to install the FreeBSD on the second partition of the
> second disk (in each case more than 100 GB) and I cannot find in any
> manual how, or even if or not, this second partition, of the second
> disk will appear in Sysinstall Program; normally, it would appear as
> a "da2" specification, but will it be recognized by FreeBSD as "a disk",
> that is, a 3rd disk ?


OK. I think you are saying that, on each disk, you have set up two MS-Win partitions. I am presuming by that you mean primary partitions and not some extended thing. You are planning on installing FreeBSD in the second primary partition, which FreeBSD would call slice 2 on disk 1. That is easily do-able.



I think SATA disks show up as ad_n. SCSI disks are da_n where 'n' is the disk number starting from 0. In that case your first disk would look like ad0 to FreeBSD and the second would be ad1. If there are two slices on each disk, they would be ad0s1 and ad0s2 on the first disk and ad1s1 and ad1s2 on the second disk. It sounds like you want to put FreeBSD on ad1s2.



If I am wrong on this identifier, then it will just be da0 and da1 as with SCSI disks. Just switch the a & d characters in all the commands.



> And if not, do I have to format, allocating the necessary space, in
> FreeBSD (Unix) system files ? This because this second partition of
> the second disk is already formatted in NTFS of Windows ... In this
> case, do I have to put exactly the measure of the partition (done in
> Windows) for formating in FreeBSD?


First, the slice will have to be converted to FreeBSD type. It does not have to be reformatted though as long as the system is able to see it as a primary slice. I think that the FreeBSD fdisk and disklabel that are used in sysinstall will take care of it. [Ed note: Almost certainly the case]



But if not, or if you are worried that they won't, then boot the CD and select to choose the fixit item from the install menu (past the boot selection menu) and then run fdisk on each disk. If you run fdisk without any other flags, it will just come back and give you information about the drive.



So, once you get the fixit disk prompt type:


$ fdisk ad0

$ fdisk ad1



and see what it tells you. It will list information for each primary slice. 1..4 and unfortunately, it is one place in FreeBSD that mucks up the terminology and calls them partitions instead of slices - I think because the fdisk routine was adapted from MS at some time in ancient history.



The two lines that say

The data for partition n is:

SYSID nn (OXnnn)......



are the meaningful ones because it tells you what each slice has on it as far as FreeBSD will know.



Your main MS-Win slice (primary partition) will probably either show up as either partition 1 or partition 2. There may be some diagnostic piece put on it by the hardware vendor that uses up slice 1 so MS starts in slice 2, but never tells you. But, FreeBSD will tell you.



Then, that second slice will show up as either partition 2 or partition 3 depending again on if there is a 'hidden' diagnostic slice on it. It should say that it is of type (0x07) NTFS and a bunch of other things if it is that second installation of MS stuff that you want to overwrite with FreeBSD.



If there is nothing else on the drive, then slice 4 and maybe slice 3 will show up with nothing on them, just the 'partition' identifier.



If you are worried about that slice being clean and ready for FreeBSD you can blast it by writing a few blocks of zeros on it using dd. Lets say it turns out to be partition 3 on the second drive (ad1) Do the command:
dd if=/dev/zero of=/dev/da1s3 bs=512 count=32
Be careful with this because if you do it to the wrong place you will wipe out something you don't want to mess with. I really think you should not need to do this anyway.



So, anyway, sysinstall will give you a list of slices that exist with space in them and are thus available for installing FreeBSD. If you want to install in the 'second' slice of that second disk, it will be ad1s2 or maybe ad1s3 if there is a 'hidden' diagnostic partition.



>I ask this because in a forum I
> noticed that somebody had some problems after leaving a little space
> between his 2 partitions of the disk (the first with Windows, the
> second of Linux).


I think the problem from that posting (if I remember correctly) was that he had a little space between slices, but not enough to install FreeBSD the way he wanted to and was wondering how to find more space. He wanted to use a utility called growfs, but that only allows it to grow if there is enough space right next to a partition, within a slice. So, he was stuck with rearranging his disk or adding one to get enough space. It is not the same as your situation. If you intend to use all of that 100GB in the 'second' slice on the second disk, you don't have to do anything extra - other than the remote possibility of having to wipe the tables on that slice using dd as I mentioned above.



> And a last thing, even more worrying: the booting and the MBR; do I have
> to leave the MBR untouched or to install the FreeBSD boot manager in MBR?
> In a Linux manual it is clearly specified, in the chapter about dual boot
> with Windows, that in this last case - if the Linux boot manager is
> installed in MBR - than Windows OS (XP or 2000) will not boot anymore ...
> So, leave the MBR untouched when installing FreeBSD or not ?


The FreeBSD MBR can boot the MS-Win systems. It works fine. I have three systems sitting right here in my office that do it with XP and W2000.



You have to tell it to install the FreeBSD MBR on both disks, not just the one where you are putting FreeBSD. That is because the MS-Win MBR is too weak to boot anything besides MS-Win. So, the way boot works in this case is:



The BIOS goes through its boot order looking for bootable media. That order is usually something like: floppy, CDrom, first hard disk Presuming you do not have a floppy or boot CD, then it reads the MBR from the first (and only the first) hard disk. The MBR then looks for bootable slices on its own drive and lists those and then looks for other hard drives that have an MBR and lists those. The bootable slices are listed as F1..F4 and any other disks with an MBR as F5..Fn, so if there are two bootable slices on the first disk (ad0) and an MBR and more bootable slices on the second disk (ad1) then it might look something like this:


    F1  MS-DOS
F2 ????
F5


Then, if you choose F5, it will transfer control to the MBR from the next disk and that one will look up the bootable slices it has. Say you had two bootable slices on that disk, with the second one being FreeBSD, it might look something like:
    F1  MS-DOS
F2 FreeBSD



You can choose F2 and FreeBSD will boot or F1 to boot whatever OS is in the MS-DOS slice.



I don't know if the sysinstall will install the MBR in both places. You might have to do that by hand in the fixit mode after things are done. Use 'fdisk -B ad0' and 'fdisk -B ad1' for this.



The '????' above comes because FreeBSD uses an honest MBR which occupies only one 512 byte disk sector as it is supposed to. That means it doesn't have much room for extra stuff. They crammed in recognizable labels for the identifiers that were know at the time it was first created, and then make all the rest be ????, including those that came on the scene after the FreeBSD MBR was created. Some other MBRs cheat and use more space under the assumption that it will not really be used by the system. That is true in most cases, but is not guaranteed. It gives them the ability to put out more fancy labels, etc at the [small] risk of something not working.



By the way, it goes by the file system type (numerical code) in the slice partition table. So, anything that uses a FAT32 or FAT16 will be called MS-DOS regardless of whether it is Win-95 or XP or Win-2000. If it is NTFS, it will display ???? regardless of which version of MS-Win it has, etc. I think there is room for 255 codes in the slice table.



I think it would be good if the FreeBSD MBR would put the sysid number it reads up along with the ???? just to help identify it, but maybe that would take too much code space.



Anyway, MS the recently (relative to the others) added the NTFS file system type came in to being after the FreeBSD MBR was created and so it gets displayed as ????. If there is a diagnostic slice, it will also probably get displayed as ????.



One more thing. This might be something to deal with at another time when you decide on its need and maybe are doing a major upgrade. FreeBSD can read NTFS filesystems, but, so far, it cannot write to them. For that reason, on systems that have NTFS for their MS system, I have put an extra FAT32 slice where I could write stuff from FreeBSD and then read it up in XP or whatever. That would mean dividing up your 100GB in to two slices - one small for sharing data and the rest for FreeBSD. I put that small transfer slice in between the MS and FreeBSD slices so it comes out as either slice 2 or 3 (if there is a diagnostic slice) and FreeBSD goes in to either slice 3 or 4. It works fine and is only needed if you want to write stuff to the MS system using NTFS.



> Excuse for my long message but I'm a little exasperated and don't
> understand why this extremely important aspects are not stressed
> enough in the BSD manuals: how to install the boot (in case of
> coexistence with other OS, mostly Windows) and how to choose and
> partition the disks already partitioned ...


Well, it is pretty well laid out in the FreeBSD handbook, though maybe not quite as pedantically as I have done above. That handbook is important reading.



> I am almost sure that many potential FreeBSD users are hold back from
> installing it because of these capital issues ...


Some of the understanding comes from reading and then just doing and seeing how it all works out. It makes a lot more sense when you try it and see it happening just as the handbook says.



For example, choosing the drive and slice on which to install; if you go ahead and run sysinstall, you will see just how it gives you the choice. Don't worry, until it says it is going to really do something, it won't make any changes and you can back out. So, just start it up and follow the steps until it says it will wipe things out and write new stuff and compare what you see with what you need.



Good luck and have fun,



////jerry






There, wasn't that worth the read? Again, I really liked how he explained about partions, in particular primary partitions, and what they are called in FreeBSD (slices). Also, personally I wouldn't bother with the FreeBSD bootloader, and would always suggest a third party one, like GAG, GRUB or, my favorite shareware one, BootIt NG.




Saturday, October 21, 2006

Out Damn Spot!

An interesting, yet common, question came up on the FreeBSD questions mailing list - "How do I delete a file that has a leading dash?" For instance, say you have a file called "-testing". Here's what happens if you try to delete it normally:



$ rm -testing

rm: illegal option -- t

usage: rm [-f | -i] [-dIPRrvW] file ...

unlink file



That's because the rm command thinks the '-t' is supposed to be an option (like the -f to force or the -r for recursive), and it doesn't recognize that option. Your first try might be to quote the file name:



$ rm "-testing"

$ rm \-testing


But that doesn't help, as it isn't the shell that's complaining but rather the rm command, which still sees the "-t" and doesn't understand it.



But as the rm man page reminds you, there are several easy ways around this problem. All of the following will work:



$ rm -- -testing

$ rm /home/usr/-testing

$ rm ./-testing



Because now the '-' isn't the first character. The '--' is a general way of telling pretty much any command that all options have ended and the rest of the command line should be processed as arguments to the command (often filenames). But the most obscure way of doing this had to be the answer using the find command to delete it by its inode number:



$ ls -i

 9232923 -testing

$ find . -inum 9232923 -exec rm {} \;



Isn't Unix wonderful? I was looking forward to seeing the answers to this question, and the thread didn't disappoint. There are so many ways of using the tools to solve problems. The find method would work for other, tough characters too.




Friday, October 20, 2006

Port ahoy!

Really nice article on the FreeBSD ports system, one of its best aspects. Also goes a bit into some of the other port interfaces, which is something I've been wondering about myself. What exactly are the pros and cons of portmaster, portmanager, and portupgrade? This article only talks about the latter one. I've been using portmanager, because it doesn't seem to depend on the package database, which I always find problematic.



The FreeBSD ports system.





Thursday, October 19, 2006

Take this job - please!

The company I work for, inSORS, is looking for a few good programmers, so in the off chance there are any good programmers in either the New England or Chicago area who read my blog, I figured I'd put the news here. It's a great company to work for, with cool technology and no commute. I've been here for about five years and am still having a great time.



Senior Software Engineer C++ Windows / Linux



Cross platform C++ architecture, design, and coding to deliver
high-performance audio, video, and data sharing applications for an
innovative grid computing enabled video conferencing and collaboration
suite. You will be using a wide range of advanced technologies and
methods, working in a fast paced exciting environment, with a great
group of dedicated people.



Job Location: Telecommute from a home
office. This is a great opportunity to work from home if you have the
appropriate time management skills, work environment and network
connectivity.

Salary: 90K+ depending on experience

Company Details: inSORS Integrated Communications
develops, markets, and supports multipoint enterprise collaboration
software and solutions.


Requirements:




* 3+ years of experience delivering production quality C++ code
* A deep understanding of network protocols and real time communications
* Experience developing multi-threaded and distributed applications
* Expert level Windows/Linux experience in C++ using Visual Studio and GCC
* Ability to work independently while cooperating with the overall team
* Minimum BSEE / BSCS or exceptional directly related equivalent experience
* Excellent written and oral communication skills


Qualified candidates should send their resume and salary requirements to:
jobs@insors.com





Charting Progress

Charting the progress of FreeBSD 4.x, 5.x, 6.x and 7.x. It's not entirely clear what the colors mean, but I think a white bar means "supported", green means "tree is open for new stuff" and red means a "frozen" release.



Current proposed FreeBSD support schedule



Wednesday, October 18, 2006

Time in a bottle

Following up on a post yesterday, I think I have my PC-BSD machine set up for NTP. I followed some advice from the Handbook (of course), as well as some from a thread on the FreeBSD Questions mailing list. I wanted it to be an NTP server for my internal network, and to sync the date periodically from the 'net. It runs 24/7, so I can't depend on a reboot to set the time. So here's what I did.



First I added the following to my /etc/rc.conf:



ntpd_enable="YES"


This sets it up so that the script at /etc/rc.d/ntpd gets run at boot up, and the ntpd daemon is allowed to run. But now we have to create a config file for it, at a bare minimum. My /etc/ntp.conf file looks like:



server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server pool.ntp.org
driftfile /var/db/ntp.drift
restrict 192.168.204.100 mask 255.255.255.0 nomodify notrap
restrict localhost


As I'm located in North America, I'm using the pool servers from there, as mentioned here. I don't think I need to specify the driftfile, as it is the same as the default. And combining Matthew Seaman's post with the handbook page, I came up with the restrict lines to allow my internal network to up date from my server. The 'restrict localhost' line actually allows all access to the localhost. Makes sense, eh? Be sure to not make the same mistake the poster in the mailing list made, and just add a 'restrict default ignore' line to the rc.conf file, like the handbook suggests. This means that the NTP daemon can't do anything, even on the local host, which isn't all that useful now is it?



Now I can run the command with the -q flag (which mimics what the older 'ntpdate' command used to do). This just runs the ntpd daemon, does its thing, and exits. This is what it looks like:



$ ntpd -q

[... long pause while it does its dance ...]

ntpd: time set +39.114227s



And now my time is spot on, at least according to Time & Date.com. So now I fire up the daemon and we should be all set:



$ /etc/rc.d/ntpd start

Starting ntpd.



You can use the ntpq command to ask about it. Here we'll ask about the list of peers it is using:



$ ntpq -p

     remote           refid      st t when poll reach   delay   offset  jitter

==============================================================================

 static-141-156- .GPS.            1 u    1   64    1   49.416   -0.157   0.001

 tire.patch.com  63.192.96.3      3 u    -   64    1  118.075   -3.792   0.001

 gandalf.llorien .INIT.          16 u    -   64    0    0.000    0.000 4000.00

 elrond.llorien. .INIT.          16 u    -   64    0    0.000    0.000 4000.00



There are a bazillion commands for ntpq, which I'm sure at least one person out there cares about, but for us mere mortals, we've pretty much exhausted the subject!




Windows decripitude

This article is entitled "index to gauge PC decripitude", but really it is the slow march of death that Windows undergoes. Very funny!



Dr. Dobb's | State of Decay | July 1, 2002



Mangled up in blue

Just found out about a cool little GNU utility that takes a "mangled" C++ subroutine name and de-mangles it to show you its declaration. Kind of a specialized thing, but sometimes when you are debugging code and you see what the C++ compiler does to your function names, you are concerned. It's good to see there is some rhyme and reason to it.




$ c++filt _ZN8DiscTypeC1ENS_4TypeE

DiscType::DiscType(DiscType::Type)




GNU Binary Utilities: c++filt






Does anyone really know what time it is?

This goes along with an earlier posting I had on the subject of ntp (found here one of my first postings!). A pretty good link for setting up NTP, albeit they talk about FreeBSD 4.x, so it is a little old. I would just skip down to the last part for setting it up, as I think it is in the standard setup now. I need to get this going on my machines, and to set up the local network to sync from this machine.



How to Install NTP on FreeBSD





Tuesday, October 17, 2006

Where oh Where has my little command gone?

While perusing some port stuff, as I try to figure out which port utility to use, I came across this little command - whereis. Now, I've actually used it before, when I couldn't find the md5 command (I didn't have /sbin in my PATH as a user). But I didn't realize it also searches the port tree for programs, which is pretty cool! For instance:



$ whereis firefox

firefox: /usr/X11R6/bin/firefox /usr/ports/www/firefox

$ whereis lsof

lsof: /usr/ports/sysutils/lsof


whereis(1)



Much nicer than some of the other ways I've used to search the ports, and more inclusive, as it even tells me if I've already had it installed. My normal method for searching ports is via the Freebsd.org web page for ports. I have a Firefox quicksearch set up, so I can pop into Firefox's address bar and type 'ports lsof' and immediately do the search. It is very simple to set this up.




  • Go to the Freebsd.org ports page here

  • Right click on the "Search ports for: " text entry box

  • Select the "Add Keyword for Search" menu item

  • Give it a name (say "FreeBSD port search") and a keyword (I use 'ports' - this is what you'll type in the address bar). Select a folder to store this "bookmark". The "Quick Searches" one is a good place:-) Then click Add.



Now you can click in the address bar and type 'ports lsof' and it will immediately do the search. This is very nice and can be done with any search-type text box. See this posting on Lifehacker.com for a good starter kit for quicksearchs:



Fifteen Firefox Quick Searches








Monday, October 16, 2006

Now play together nice!

Got another little thing working in my PC-BSD installation - getting Firefox and Thunderbird to work together. Now, when I click on a link in my email program Thunderbird, it opens in Firefox (instead of the drag'n'drop I had to do before). And when I click on a mailto link or do a Tools->New Message in Firefox, it opens up a new message in Thunderbird. And, unlike on Windows, when I do that the signature even shows up correctly. Wee haa!



How To Integrate Firefox and Thunderbird



The only thing I would change in the first posting is, as mentioned in the last message, use the more generic spot for the programs, rather than the funky PBI "/Programs" spot, which also includes the version number. For me, firefox (built from ports) was in /usr/X11R6/bin, and thunderbird (via a PBI) was in /usr/local/bin/. Also, in firefox, you can do the "about:config" trick and just paste a new key in there, rather than hand-editing the file.



Oh, and be sure to heed the advice at the bottom - close Thunderbird before editing the prefs.js file, as the last thing Thunderbird does before exiting is to overwrite it. So if you edit the file then exit Thunderbird, you lose your changes. Yup, I did it that way the first time...





Change is Good

I've been thinking about recompiling the kernel and tweaking it a bit for my PC-BSD machine. I just found out the custom kernel config file used in the building of PC-BSD is found here:




/PCBSD/conf/PCBSDv1.2



So you would start with that and go from there. My next task was going to be to get multimedia to work, as I wasn't able to play movies or audio, but then all of a sudden it all started playing via Kaffeine, so I can't complain. Well, I can a little bit, as I couldn't get CD audio to work for some reason, although I didn't play with it for too long, as I got my WZBC audio feed working, so I was a happy camper.




Saturday, October 14, 2006

iX {hearts} PC-BSD

Good analysis of the new iXsystems and PC-BSD merger, along with interviews with Kris Moore and Matt Olander.



NewsForge | Why iXsystems bought PC-BSD





Friday, October 13, 2006

Keep your job for life

Very funny page on how to write code that is unreadable, unmaintainable and unbelievable. Unfortunately, I see many of these "bad practices" nearly every day:-(



How To Write Unmaintainable Code





Thursday, October 12, 2006

PC-BSD goes pro

Jeez, I go away for a few days and the whole world changes! Well, maybe it hasn't, but still, it is interesting news that iXsystems has "acquired" PC-BSD, my currently installed FreeBSD version. I guess objectively speaking, it should be good news, and has already paid off by making Kris Moore, the brains behind PC-BSD, a full time PC-BSD worker, which can only mean good things. But there are so many ways this could go wrong it is scary. I hope it remains the vibrant, user-supported FreeBSD variation that attracted me to it in the first place.



Here is a link to a long thread about it in the PC-BSD forums: PC-BSD Forum :: iXsystems and PC-BSD



Here's the official announcement: iXsystems Announces Acquisition of PC-BSD Operating System






Saturday, October 7, 2006

CMS for life

We've been evaluating CMS software and I'm amazed at the breadth of offerings, just in the free/PHP4/MySQL arena. I haven't been bowled over by any yet, but it's still early in the evaluation process. We've defined what we're looking for and now we are examining candidates. A tricky thing is to figure out how well each would handle a big demand, in the off chance our web site should become really popular. And it doesn't seem like switching your CMS (Content Management System) (or even a CMF - Framework) is something you could easily do. So we're trying to be very careful here.



We've come across a couple of sites with long lists of contenders. The first only considers free, PHP4, MySQL CMS packages, and even with that stringent requirement, there must be over 50 listed. There's even demo setups for each of them, which is really cool. Also neat are the user comments for each.



OpenSourceCMS



The other one doesn't even narrow it down that far, but it does let you compare a matrix of features, talk about each and rate them.



The CMS Matrix - The Content Management Comparison Tool







Friday, October 6, 2006

Another dragon slayed

Yet another blockade blasted down! I finally got printing to work. I long ago gave up trying to share the printers directly from my PC-BSD box with the Windows computers on the network, so I had moved both the laser printer and the Canon color printer over to my work box, which runs WinXP Pro, and shared them from there. But I just couldn't get connected to them from my PC-BSD box, although Samba seemed to be running like a charm.



Awhile ago, I was having problems with the cups server hanging as I was booting up, so I changed the line in my /etc/rc.conf to say:




cupsd_enable="NO"



instead of yes. But you really need to have cupsd running if you're going to do any printing from your Linux or BSD box, so I decided to try and get it running, by connecting it to the printers on my Windows box via Samba. But whenever I'd run the Printers item from KDE, I'd get some strange error about unable to connect to the cups via IPP or some such.



And then I noticed that even Samba had stopped working, and when I tried to get it started from the commandline, it too gave me the same error things like kdeprint were giving me - libgnutls.so.15 couldn't be found. Now I have no idea what this is or where it went to.



So I did a "portmanager net/samba3" to upgrade my Samba and then that started working again. And I found out that you do CUPS configuration via the web browser, by connecting to localhost:631. So I did that and added a printer via Samba, using the "URI" of smb://delldual/ML-1430 (for my Samsung 1430 laser printer on my Dell Dual CPU system). And, surprise surprise, it all worked! My Canon i560 photoprinter was a little more problematic, as there isn't a direct printer driver for it. But it looks like the BJ-8700 driver is a fair match, so I used that. And I could even printer in color from OpenOffice, by using a magical incantation, as found on the PC-BSD forums and in the OpenOffice SETUP GUIDE:




$ /Programs/OpenOffice.org2.0.3/program/spadmin



spadmin is the "Printer Administration" program for OO, and will probably be found somewhere else, as that location is where the OO PBI stores it. In there, you make printer be 'kprinter -stdin' (assuming you are using KDE - the setup guide says for Gnome users to use the "Gnome equivalent" - if you know what it is, please leave a comment). Now I get the KDE Printer setup dialog when I print, and I was even able to print in color. Woo Hoo!



Hush Baby

So someone asked on freebsd questions about how to make his login shell stop printing out the fortune. He even went so far as to rename the fortune program! I guess he must have been running a system-wide default .login or .rc file of some sort, but that's a little over the top, don't you think? The easiest way would have been to create his own .login and/or .rc file (.profile and/or .bashrc for bash) and just not call fortune in it. But Norberto pointed out another way, that I hadn't heard of - the .hushlogin file:




$ touch ~/.hushlogin



I had never heard of that, but what it does is to make all login displays not show up. Which is pretty cool, if you ask me. So even the motd won't spoil your pristine login window. Nice. Here's an article on O'Reily about the whole log in procedure, including .hushlogin:



Monitoring Unix Logins


Tuesday, October 3, 2006

bash is a 4 letter word

Ever wonder what those strange command names mean in Unix? 'brief is beautiful' is definitely the mantra for most Unix command names, and here's an explanation for most of them.



The Unix Acronym List: Unix Commands






Color my world

Pretty good little quicky chart showing the HTML color values.



Complete HTML True Color Chart






Emacs and Mr. Clipboard

I finally figured out how to get Emacs to use the X Clipboard. In the Customize | Editing | Killing page, at the bottom there is a toggle for "X Select Enable Clipboard". This defaults to nil, so toggle it to t in order to have text that you Copy go into the X clipboard as well. If you want to do this by hand:




(setq x-select-enable-clipboard t)


should go into your .emacs file. One small victory, as I move towards a happy full-time existence in BSD land. Now to fix a few of my other problems:



Things I miss from Windows:




  • Google Toolbar w/spellchecking

  • Comcast Rhapsody

  • My title bar shortcut menu PowerPro)

  • No multimedia working yet. No WMV/AVI. No YouTube/Google Video

  • Flash. While in general I hate flash, and I never could get it to work for my Firefox on Windows, some sites require it. I used to just use the "View Site in IE" or Opera shortcut on Windows. It is one reason I've been trying to get them to work using some kind of Windows tool.





Getting Jiggy with my dual monitors

Well, my dual monitor setup seems to be working finally. Not sure exactly what I did to make it work, though, as I flailed about pretty wildly for awhile. I upgraded my X.org server, as I think PC-BSD 1.2 is one release behind. I've also tweaked my xorg.conf file to set both displays to have the same resolution, thinking maybe the mismatch resolutions was making it hard on the software. I'm not sure what exactly, but it is working for me now. Here's my current xorg.conf:




Section "ServerLayout"
Identifier "Radeon Dual Monitor"
Screen 0 "Screen0" 0 0
Screen "Screen1" LeftOf "Screen0"
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
FontPath "/usr/X11R6/lib/X11/fonts/TTF"
FontPath "/usr/X11R6/lib/X11/fonts/TrueType"
FontPath "/usr/X11R6/lib/X11/fonts/URW"
# FontPath "/usr/X11R6/lib/X11/fonts/ae_fonts1"
# FontPath "/usr/X11R6/lib/X11/fonts/azeri"
FontPath "/usr/X11R6/lib/X11/fonts/bitstream-vera"
FontPath "/usr/X11R6/lib/X11/fonts/dejavu"
# FontPath "/usr/X11R6/lib/X11/fonts/encodings"
# FontPath "/usr/X11R6/lib/X11/fonts/fonts.cache-1"
FontPath "/usr/X11R6/lib/X11/fonts/freefonts"
# FontPath "/usr/X11R6/lib/X11/fonts/indic"
FontPath "/usr/X11R6/lib/X11/fonts/local"
# FontPath "/usr/X11R6/lib/X11/fonts/luxi"
FontPath "/usr/X11R6/lib/X11/fonts/misc"
FontPath "/usr/X11R6/lib/X11/fonts/omega"
FontPath "/usr/X11R6/lib/X11/fonts/URW"
# FontPath "/usr/X11R6/lib/X11/fonts/util"
EndSection


Section "Module"
Load "extmod"
Load "glx"
Load "dri"
Load "dbe"
# Load "record"
# Load "xtrap"
Load "type1"
Load "freetype"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/sysmouse"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
#DisplaySize 280 210 # mm
Identifier "LCD-Mon"
VendorName "PTS"
ModelName "PZ456"
### Comment all HorizSync and VertSync values to use DDC:
# HorizSync 30.0 - 60.0
VertRefresh 61.0 - 75.0
Option "DPMS"
EndSection

Section "Monitor"
#DisplaySize 350 260 # mm
Identifier "CRT-Mon"
VendorName "SAM"
ModelName "SyncMaster"
### Comment all HorizSync and VertSync values to use DDC:
HorizSync 30.0 - 96.0
VertRefresh 50.0 - 160.0
Option "DPMS"
EndSection

Section "Device"
Identifier "ATI Port 1"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "R480 [Radeon X850Pro]"
BusID "PCI:1:0:0"

# MergedFB options
Option "MergedFB" "True"
Option "CRT2Position" "RightOf"
# Option "MetaModes" "2048x768-2048x768"
Option "RenderAccel" "True" # []
Option "DMAForXv" "True" # []

# Option "EnablePageFlip" "True"
# Option "AGPMode" "4"
# Option "AGPFastWrite" "True"
# Option "MergedXineramaCRT2IsScreen0" "True"
# Option "Xinerama" "True"
EndSection

Section "Device"
Identifier "ATI Port 2"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "R480 [Radeon X850Pro]"
BusID "PCI:1:0:1"
EndSection

Section "Screen"
Identifier "Screen0"
Device "ATI Port 2"
Monitor "CRT-Mon"
DefaultDepth 24
SubSection "Display"
Depth 24
Virtual 2048 768
# Modes "1280x1024" "1024x768" "800x600"
Modes "1024x768" "800x600"
EndSubSection
EndSection

Section "Screen"
Identifier "Screen1"
Device "ATI Port 1"
Monitor "LCD-Mon"
DefaultDepth 24
SubSection "Display"
Depth 24
Virtual 2048 768
Modes "1024x768" "800x600"
EndSubSection
EndSection

# Make it so other users can use DRI
Section "DRI"
Mode 0666
EndSection


Trevor was kind enough to post his working xorg.conf, although it confuses me because it doesn't have two "Screen" sections. I wonder if it is because his displays are identical 19" Samsungs? Anyway, here's his working xorg.conf:




Section "ServerLayout"
Identifier "X.org Configured"
Screen 0 "Screen0" 0 0
InputDevice "Mouse0" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection

Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
ModulePath "/usr/X11R6/lib/modules"
FontPath "/usr/X11R6/lib/X11/fonts/webfonts/"
FontPath "/usr/X11R6/lib/X11/fonts/urwfonts-ttf/"
FontPath "/usr/X11R6/lib/X11/fonts/URW/"
FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/TTF/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
EndSection

Section "Module"
Load "extmod"
Load "dri"
Load "dbe"
# Load "record"
# Load "xtrap"
Load "glx"
Load "type1"
Load "freetype"
EndSection

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
EndSection

Section "InputDevice"
Identifier "Mouse0"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/psm0"
Option "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
Identifier "Monitor0"
VendorName "SAM"
ModelName "SyncMaster"
Option "DPMS"
EndSection

Section "Device"
Identifier "Card0"
Driver "ati"
VendorName "ATI Technologies Inc"
BoardName "RV350 AS [Radeon 9550]"
BusID "PCI:1:0:0"

Option "AGPMode" "4"
# This MAKEM BIG LOCKUP
# Option "AGPFastWrite" "True" # []
Option "MergedDPI" "100 100" # []
Option "MergedFB" "True" # []
Option "CRT2Position" "RightOf" # []
Option "MetaModes" "1280x1024-1280x1024"
Option "RenderAccel" "True" # []
Option "DMAForXv" "True" # []
EndSection

Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"
Virtual 2560 1024
EndSubSection
EndSection


It was the first I had heard of the MetaModes option, so I played with that a bit. You specify the resolutions for the two displays, so maybe that's how his works. I didn't know that and that's why mine is commented out. It should be:




Option "MetaModes" "1024x768-1024x768"


Although my next step will be to bump the resolution for my 19in monitor to be 1280x1024, so the line will look like:




Option "MetaModes" "1280x1024-1024x768"


I also duplicated the "RenderAccel" and "DMAForXv" options, although I'm not clear on what they do. But it has bee pretty solid so far, so I think I have a working baseline xorg.conf. But am I happy enough to just leave it well enough alone? Noooooooooooo...



Monday, October 2, 2006

Tainted by evil

As much as I hate the idea, sometimes you just have to run Windows apps. I've pretty much made a clean break but some things just require to ubiquitous Windows. I haven't had much luck with WINE, as there seems to be some kind of thread problem. I was hoping to use it to run Firefox + Flash, which is something that just doesn't work on FreeBSD. But neither Firefox nor Opera would work using WINE.



I also dual boot into WIndows to play computer games, although WINE claims to be able to run several of the games I play. But here's another entry in the "Run WIndows apps transparently on your FreeBSD machine", called "Win4BSD", an offshoot, I guess, of a Linux version called Win4Lin. I might have to check it out, even if it does seem to be commercial software.



win4bsd - Home