<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>my core dump is your sigfault</title>
	<atom:link href="http://vodoom.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vodoom.wordpress.com</link>
	<description></description>
	<lastBuildDate>Fri, 16 Sep 2011 20:49:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='vodoom.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>my core dump is your sigfault</title>
		<link>http://vodoom.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vodoom.wordpress.com/osd.xml" title="my core dump is your sigfault" />
	<atom:link rel='hub' href='http://vodoom.wordpress.com/?pushpress=hub'/>
		<item>
		<title>simple and dirty FIX 4.2 parser and decoder</title>
		<link>http://vodoom.wordpress.com/2010/11/03/simple-and-dirty-fix-4-2-decoder/</link>
		<comments>http://vodoom.wordpress.com/2010/11/03/simple-and-dirty-fix-4-2-decoder/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 01:19:41 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[BSD]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[FIX]]></category>
		<category><![CDATA[trading]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=345</guid>
		<description><![CDATA[Since I spend some of my time dealing with FIX messages, I wrote this little FIX decoder yesterday night. It is simple (very simple) but does a pretty good job at decoding a fix message. You can find the code here. I kept it simple and easy to modify/extend for my own needs: I open [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=345&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since I spend some of my time dealing with <a href="http://www.fixprotocol.org/specifications/FIX.4.2">FIX </a>messages, I wrote this little FIX decoder yesterday night.<br />
It is simple (very simple) but does a pretty good job at decoding a fix message. You can find the code <a href="http://bitbucket.org/ppi/fix/overview">here</a>.</p>
<p>I kept it simple and easy to modify/extend for my own needs: I open some messages snippets in vim and I want to get a decoded version of the message right away, selecting the line I was on and calling a program to dump the decoded buffer. Very useful when I am dealing with rare tags or when I was not doing some FIX for a while.</p>
<p>Well, this little code does just that. I added also a section where I can add the local dictionary used by my employer (very helpful).</p>
<p>the code is provided with a <a href="http://en.wikipedia.org/wiki/BSD_licenses#3-clause_license_.28.22New_BSD_License.22.29">BSD licence</a> i.e. yes you can put/use it in commercial code.</p>
<p>compiled/edited on a linux box, but it should be pretty easy to port to whatever platform you want run it.</p>
<p>it is simple to compile:<br />
<code><br />
c++ fixdecode.cpp -g -o a.out<br />
</code></p>
<p>it is simple to run:<br />
<code><br />
./a.out   &lt; ExampleFixMessages.txt<br />
</code><span style="font-family:monospace;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
</span><span style="font-family:monospace;">83 bytes have been retrieved &#8217;8=FIX.4.19=6135=A49=BRKR56=INVMGR98=034=152=20000426-12:05:08108=3010=143&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[   8]               BeginString &#8216;FIX.4.1&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[   9]                BodyLength &#8217;61&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  35]                   MsgType &#8216;A&#8217;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  49]              SenderCompID &#8216;BRKR&#8217;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  56]              TargetCompID &#8216;INVMGR&#8217;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  98]             EncryptMethod &#8217;0&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  34]                 MsgSeqNum &#8217;1&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  52]               SendingTime &#8217;20000426-12:05:08&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[ 108]                HeartBtInt &#8217;30&#8242;<br />
</span><span style="font-family:monospace;line-height:18px;font-size:12px;white-space:pre;">[  10]                  CheckSum &#8217;143&#8242;<br />
</span><span style="font-family:monospace;">-&gt; OK 83 B<br />
</span><span style="font-family:monospace;">&#8230;</span></p>
<p>Under vi I just select line and apply a.out to it, and it dumps this helpful message.</p>
<p>Enjoy and share</p>
<br />Filed under: <a href='http://vodoom.wordpress.com/category/programming/'>programming</a>, <a href='http://vodoom.wordpress.com/category/software-development/'>software development</a>, <a href='http://vodoom.wordpress.com/category/unix/'>unix</a> Tagged: <a href='http://vodoom.wordpress.com/tag/bsd/'>BSD</a>, <a href='http://vodoom.wordpress.com/tag/code/'>code</a>, <a href='http://vodoom.wordpress.com/tag/fix/'>FIX</a>, <a href='http://vodoom.wordpress.com/tag/trading/'>trading</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/345/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/345/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/345/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=345&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2010/11/03/simple-and-dirty-fix-4-2-decoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>ion3 repository and patches on bitbucket</title>
		<link>http://vodoom.wordpress.com/2010/10/13/ion3-repository-on-httpbitbucket-orgppianionoverview/</link>
		<comments>http://vodoom.wordpress.com/2010/10/13/ion3-repository-on-httpbitbucket-orgppianionoverview/#comments</comments>
		<pubDate>Wed, 13 Oct 2010 22:40:37 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[ion3]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[window manager]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=341</guid>
		<description><![CDATA[I just added a repository on bitbucket, where I uploaded ion 20090110 with the latest patches from Tuomo Valkonen. I updated the system.mk to match my system, centos/ubuntu. I intend to fix bugs reported to me on this code but I do not intend to add any new feature for now. This code will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=341&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I just added a <a href="http://bitbucket.org/ppi/anion/overview">repository </a> on <a href="http://bitbucket.org">bitbucket</a>, where I uploaded ion 20090110 with the latest patches from Tuomo Valkonen.<br />
I updated the system.mk to match my system, centos/ubuntu.</p>
<p>I intend to fix bugs reported to me on this code but I do not intend to add any new feature for now.<br />
This code will be maintained but won&#8217;t get any new feature from me. At some point this may change but for now, this is it.</p>
<p>If somebody sends bug reports or want me to fix a bug quickly, you better send me a very good report and a method to reproduce the bug :-)</p>
<br />Filed under: <a href='http://vodoom.wordpress.com/category/ion3/'>ion3</a>, <a href='http://vodoom.wordpress.com/category/software-development/'>software development</a>, <a href='http://vodoom.wordpress.com/category/unix/'>unix</a>, <a href='http://vodoom.wordpress.com/category/window-manager/'>window manager</a>, <a href='http://vodoom.wordpress.com/category/x11/'>X11</a> Tagged: <a href='http://vodoom.wordpress.com/tag/ion3/'>ion3</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/341/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/341/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/341/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=341&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2010/10/13/ion3-repository-on-httpbitbucket-orgppianionoverview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>gnu/stubs-32.h: No such file or directory</title>
		<link>http://vodoom.wordpress.com/2010/08/31/gnustubs-32-h-no-such-file-or-directory/</link>
		<comments>http://vodoom.wordpress.com/2010/08/31/gnustubs-32-h-no-such-file-or-directory/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 13:29:24 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[gcc]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=336</guid>
		<description><![CDATA[Written here so I won&#8217;t forget it next time: on REHL if I want to compile a 32 bit app with my gcc 64bit compiler I need to install glibc-devel.i386. I always forget this guy when setting up my wokstation. And of course I always stumble upon it each time I have to compile a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=336&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Written here so I won&#8217;t forget it next time: on <a href="http://www.redhat.com/rhel/">REHL </a>if I want to<br />
compile a 32 bit app with my gcc 64bit compiler I need to install<br />
<code>glibc-devel.i386</code>.  I always forget this guy when setting up my wokstation.<br />
And of course I always stumble upon it each time I have to compile a<br />
legacy app. This small line solves the problem:</p>
<p><code>sudo yum install glibc-devel.i386</code></p>
<br />Filed under: <a href='http://vodoom.wordpress.com/category/programming/'>programming</a> Tagged: <a href='http://vodoom.wordpress.com/tag/c/'>c</a>, <a href='http://vodoom.wordpress.com/tag/gcc/'>gcc</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/336/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/336/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/336/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=336&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2010/08/31/gnustubs-32-h-no-such-file-or-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>making a backup of my gmail account with fetchmail and procmail</title>
		<link>http://vodoom.wordpress.com/2010/02/09/making-a-backup-of-my-gmail-account-with-fetchmail-and-procmail/</link>
		<comments>http://vodoom.wordpress.com/2010/02/09/making-a-backup-of-my-gmail-account-with-fetchmail-and-procmail/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 00:40:55 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[fetchmail]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[procmail]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=324</guid>
		<description><![CDATA[Gentle introduction to email terminology In this post I&#8217;ll be talking about procmail, fetchmail and mutt. Three programs to read and backup emails &#8230; Wait, three programs just to read emails !? None sens ! Well, actually it makes perfect sens: to read an email on your computer with your favorite email client, you need to follow these [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=324&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Gentle introduction to email terminology</h2>
<p>In this post I&#8217;ll be talking about procmail, fetchmail and mutt. Three programs to read and backup emails &#8230; Wait, three programs just to read emails !? None sens !<br />
Well, actually it makes perfect sens: to read an email on your computer with your favorite email client, you need to follow these steps:</p>
<ol>
<li>grab the email from your email provider (connect and download)</li>
<li>filter/process is the email (in which mailbox do we store it &#8211; possibly the spam mailbox, or your regular inbox)</li>
<li>read it</li>
</ol>
<p>For each of these steps, the following jargon is used:</p>
<ul>
<li>when you download your email, you are using a mail transfer agent i.e. <a href="http://en.wikipedia.org/wiki/Mail_transfer_agent" target="_blank">MTA</a></li>
<li>when filtering/processing it, you are using a mail delivery agent i.e. <a href="http://en.wikipedia.org/wiki/Mail_delivery_agent" target="_blank">MDA</a></li>
<li>and finally when reading it, you are using a mail user agent i.e. <a href="http://en.wikipedia.org/w/index.php?title=Mail_user_agent" target="_blank">MUA</a></li>
</ul>
<p>Weird ? Not really if you know the UNIX philosophy: each program does one<br />
thing, but it does it well (Yeah, I know: sounds like a real cliche).</p>
<p>When you use thunderbird or outlook, you are using a MTA, MDA and MUA at the<br />
same time. I will not talk about mail submission agent<br />
<a href="http://en.wikipedia.org/wiki/Mail_submission_agent" target="_blank">MSA</a> that is in charge of sending the email you wrote: this is out of scope :-).</p>
<p>Ok, now let&#8217;s go back to the purpose of this post: backing up my gmail account.</p>
<h2>the big plan</h2>
<p>So, given the previous steps described above, I will:</p>
<ul>
<li>use fetchmail as my MTA to connect to gmail and retrieve my emails</li>
<li>use procmail as my MDA to store the content in the various mailboxes</li>
<li>read it on mutt, yes mutt is my MUA</li>
</ul>
<h2>step 1: retrieving mail with fetchmail</h2>
<h3>configuring my gmail account</h3>
<p>google provides access to my email using <a href="http://en.wikipedia.org/wiki/Post_Office_Protocol" target="_blank">POP3</a> or <a href="http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" target="_blank">IMAP</a>.</p>
<p>I will retrieve my email using POP3, google provides interesting features for it. The one I am interested in is located at <strong>settings -&gt; forward and pop/imap -&gt; POP download</strong>.<br />
Here I select &#8220;Enable POP for all mail (even mail that&#8217;s already been downloaded)&#8221;: it will allow me to download all my emails, including the ones I already did read.<br />
<strong> WARNING</strong>: be sure to select &#8220;When messages are accessed with POP &#8211; keep gmail&#8217;s copy in inbox&#8221; otherwise, gmail will remove your downloaded email<br />
from your account &#8211; which is not my intent.</p>
<p>I also select, in the same page, enabling IMAP, so I can read my emails from everywhere using the IMAP protocol which allows me to view my emails from<br />
anywhere while keeping them on the server i.e. I browse them, when I finish reading my mail, it&#8217;s still there on the server: be sure to check <a href="http://en.wikipedia.org/wiki/Internet_Message_Access_Protocol" target="_blank">IMAP</a> wikipedia entry.</p>
<p>I download them only for backup purpose and use POP3 for that.</p>
<p>Do not forget to save the changes you made to your google account &#8230;</p>
<h3>dealing with gmail server security</h3>
<p>Access to my account is encrypted (a good thing) hence I need to setup some security before beeing able to download some emails.<br />
SSL as used by google, requires you to download some credentials from a certificate authority; it is used to authenticate google server i.e. making sure you really are connecting to google and not to some random (and possibly malicious) server.</p>
<p>First, I need to retrieve the certificate of the CA used by google:</p>
<pre>
# wget -O Equifax_Secure_Certificate_Authority.pem https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Certificate_Authority.cer
</pre>
<p>and convert it to something that can actually be used by our beloved ssl tools:</p>
<pre>
# openssl x509 -in Equifax_Secure_Certificate_Authority.pem -fingerprint -subject -issuer -serial -hash -noout
</pre>
<p>I now store it where they can latter be referenced and checked. Since I am always setting up workstations when moving from one workplace to another, I store that kind of information in the UNIX account that has been given to me:</p>
<pre>
# mkdir ~/.certificates
# mv Equifax_Secure_Certificate_Authority.pem ~/.certificates
</pre>
<p>Now I make them available to the various programs I use:</p>
<pre>
# c_rehash ~/.certificates
</pre>
<p>On opensolaris c_rehash is not available (I don&#8217;t know why). It&#8217;s a perl script and I found a version using google code <a href="http://www.google.com/codesearch/p?hl=en#2CnO_mGaYOA/source/openssl-0.9.8.tar.gz|RUDwtLKIcqo/openssl-0.9.8/tools/c_rehash&amp;q=c_rehash" target="_blank">here</a>.</p>
<p>cut and paste this code into a file named c_rehash and execute it:</p>
<pre>
# cd ~
# perl c_rehash .certificates
Doing .certificates/
Equifax_Secure_Certificate_Authority.pem =&gt; 594f1775.0
</pre>
<p>This is it for the security part, SSL credentials are now ready to be used by fetchmail.</p>
<h3>configuring fetchmail for POP access</h3>
<p>my gmail account is something like:</p>
<ul>
<li>user &#8216;vodoom@gmail.com&#8217;</li>
<li>pop3 server is &#8216;pop.gmail.com&#8217;</li>
</ul>
<p>my local settings are:</p>
<ul>
<li>user on my machine is &#8216;ppereira&#8217;</li>
<li>my google certificate is located at &#8216;~/.certificates&#8217; (see previous step)</li>
<li>mda to be used is &#8216;procmail&#8217; (more on that later)</li>
</ul>
<p>The corresponding fetchmail configuration (to be stored in ~/.fetchmailrc):</p>
<pre>
set daemon 600
poll pop.gmail.com with proto POP3 and options no dns
user 'vodoom@gmail.com' there is 'ppi' here
options keep ssl sslcertck sslcertpath '~/.certificates'
mda '/usr/bin/procmail -d %T'
</pre>
<p>For more details about these options, see <a href="http://fetchmail.info/fetchmail-man.html" target="_blank">fetchmail&#8217;s manual</a>.</p>
<h2>configuring procmail for delivery</h2>
<h3>spam filtering ?</h3>
<p>Note that there is no spam filtering configuration here: since this setup is only for my gmail account, I rely on gmail spam filter to take care of those.<br />
If you need a spam filtering setup, you may want to have a look at http://wiki.apache.org/spamassassin/UsedViaProcmail.</p>
<h3>managing my mailing lists</h3>
<p>I use the TO_ recipe rule of procmail: I do not use the list-id header, it is more covenient for me as explained in http://www.ii.com/internet/robots/procmail/qs/#alt2TO.<br />
Procmail recipes are matching rules associated with a mailbox (yes, I am over simplifying).<br />
For example, here is a simple recipe:</p>
<pre>
:0:
* ^TO_zfs-discuss@opensolaris.org
osol-zfs
</pre>
<p><code>:0:</code> is the delivery options, in my case I want locking when accessing to the inbox (that&#8217;s the second &#8216;:&#8217;)</p>
<p><code>* ^TO_zfs-discuss@opensolaris.org</code><br />
means that we want to match messages that were sent to zfs-discuss@opensolaris.org<br />
One can use regular expressions and special matching rules e.g. ^From to create a matching rule.</p>
<p><code>osol-zfs</code> tells procmail to store this email in the mailbox &#8216;osol-zfs&#8217;</p>
<p>here are my recipes to match the mailing lists I am subscribed to:</p>
<pre>
:0:
* ^TO_zfs-discuss@opensolaris.org
osol-zfs

:0:
* ^TO_perf-discuss@opensolaris.org
osol-perf

:0:
* ^TO_opensolaris-code@opensolaris.org
osol-code

:0:
* ^TO_opensolaris-announce@opensolaris.org
osol-announce

:0:
* ^TO_indiana-discuss@opensolaris.org
osol-indiana

:0:
* ^TO_ogb-discuss@opensolaris.org
osol-board

:0:
* ^TO_eeepc-discuss@opensolaris.org
osol-eeepc

:0:
* ^TO_crypto-discuss@opensolaris.org
osol-crypto

:0:
* ^TO_xvid-devel@xvid.org
xvid-devel

:0:
* ^TO_users@crater.dragonflybsd.org
dragonfly-bsd
</pre>
<p>All those recipes are stored in their own file: rc.mailing-lists.<br />
This file will be included from a &#8216;master&#8217; file, the main .procmailrc file.<br />
The .procmailrc file looks like:</p>
<pre>
# Directory for storing procmail configuration and log files
# You can name this variable anything you like, for example
# PROCMAILDIR, or don't set it (but then don't refer to it!)
PROCMAIL_DIR=$HOME/procmail
SHELL=/bin/sh

# LOGFILE should be specified ASAP so everything below it is logged
LOGFILE=$PROCMAIL_DIR/procmail.log

# where are the various mailboxes stored ?
# note that this is *not* the location of the system email
# this is where I want my mailboxes to be stored by procmail i.e. the
# destination after filtering
MAILDIR=$HOME/mail

# recipes/filters are included from here
INCLUDERC=$PROCMAIL_DIR/rc.mailing-lists
INCLUDERC=$PROCMAIL_DIR/rc.banking
</pre>
<p>Now that procmail is setup, time to retrieve some emails:</p>
<pre>
# fetchmail -vk
File /export/home/ppi/.fetchmailrc must have no more than -rwx--x--- (0710) permissions.
</pre>
<p>oops I forgot to setup the proper permissions for the .fetchmailrc file,<br />
let&#8217;s fix that:</p>
<pre>
# chmod 710 .fetchmailrc
</pre>
<p>Running it again, and failing again for a very different reason, from my logfile in ~/fetchmail/fetchmail.log:</p>
<pre>
fetchmail: starting fetchmail 6.3.8 daemon
fetchmail: 6.3.8 querying pop.gmail.com (protocol POP3) at Thu Jan 28 00:06:43 2010: poll started
fetchmail: getaddrinfo("pop.gmail.com","pop3s") error: service name not available for the specified socket type
fetchmail: Try adding the --service option (see also FAQ item R12).
fetchmail: POP3 connection to pop.gmail.com failed: Bad file number
fetchmail: 6.3.8 querying pop.gmail.com (protocol POP3) at Thu Jan 28 00:06:43 2010: poll completed
fetchmail: Query status=2 (SOCKET)
fetchmail: sleeping at Thu Jan 28 00:06:43 2010 for 600 seconds
</pre>
<p>hum, fetchmail is looking for the port number corresponding to the &#8216;pop3s&#8217; service. AFAIK, on my opensolaris box I don&#8217;t have such service configured:</p>
<pre>
# grep -i pop3s /etc/services
#
</pre>
<p>To connect to gmail I have to manually setup use the port number<br />
corresponding to &#8216;pop3s&#8217;, as suggested by fetchmail in the log:<br />
<code><br />
'fetchmail: Try adding the --service option (see also FAQ item R12).'<br />
</code><br />
so here I go again:<br />
<code><br />
# fetchmail -vk --service 995<br />
</code><br />
now from my fetchmail log I can see:</p>
<pre>
fetchmail: 6.3.8 querying pop.gmail.com (protocol POP3) at Fri Jan 29 00:15:07 2010: poll started
fetchmail: Trying to connect to 74.125.93.111/995...connected.
fetchmail: Issuer Organization: Google Inc
fetchmail: Issuer CommonName: Google Internet Authority
fetchmail: Server CommonName: pop.gmail.com
fetchmail: pop.gmail.com key fingerprint: 92:73:17:4C:34:4B:68:F7:B2:17:71:42:0D:7F:9F:33
fetchmail: POP3&lt; +OK Gpop ready for requests from 70.31.248.56 8pf4635265qwj.1
fetchmail: POP3&gt; CAPA
fetchmail: POP3&lt; +OK Capability list follows
fetchmail: POP3&lt; USER
fetchmail: POP3&lt; RESP-CODES
fetchmail: POP3&lt; EXPIRE 0
fetchmail: POP3&lt; LOGIN-DELAY 300
fetchmail: POP3&lt; X-GOOGLE-VERHOEVEN
fetchmail: POP3&lt; UIDL
fetchmail: POP3&lt; .
fetchmail: POP3&gt; USER vodoom@gmail.com
fetchmail: POP3&lt; +OK send PASS
fetchmail: POP3&gt; PASS *
fetchmail: POP3&lt; +OK Welcome.
fetchmail: POP3&gt; STAT
fetchmail: POP3&lt; +OK 354 21544383
fetchmail: POP3&gt; LAST
fetchmail: POP3&lt; -ERR Not supported
fetchmail: Not supported
fetchmail: POP3&gt; UIDL
fetchmail: POP3&lt; +OK
fetchmail: POP3&lt; 1 GmailIdfbe952ed20bfe97
fetchmail: POP3&lt; 2 GmailIdfc26b09f74e3775
fetchmail: POP3&lt; 3 GmailIdfc6f980243d2a13
fetchmail: POP3&lt; 4 GmailId1043d10888f8ed70
...
fetchmail: POP3&lt; 354 GmailId10e7b3433c301f94
fetchmail: POP3&lt; .
fetchmail: 354 messages for vodoom@gmail.com at pop.gmail.com (21544383 octets).
fetchmail: POP3&gt; LIST 1
fetchmail: POP3&lt; +OK 1 1694617
fetchmail: POP3&gt; RETR 1
fetchmail: POP3&lt; +OK message follows
fetchmail: reading message vodoom@gmail.com@pop.gmail.com:1 of 354 (1694617 octets)
...
</pre>
<p>Yes ! This is working :-)</p>
<p>So now my gmail account is backed up. From time to time I run my fetchmail script, and it downloads the new emails that are not yet backed up.<br />
If like me you have thousands of emails waiting to be download, be patient, as emails are not downloaded in a single connection: each connection will download hundreds of emails, fetchmail will have to reconnect to download the rest. This is fine, that&#8217;s why I setup the daemon mode in fetchmail :-).</p>
<p>Ok now I have to access my emails with IMAP, but thats another post :-)</p>
<p>enjoy and share.</p>
<br />Filed under: <a href='http://vodoom.wordpress.com/category/configuration/'>configuration</a>, <a href='http://vodoom.wordpress.com/category/email/'>email</a>, <a href='http://vodoom.wordpress.com/category/unix/'>unix</a> Tagged: <a href='http://vodoom.wordpress.com/tag/backup/'>backup</a>, <a href='http://vodoom.wordpress.com/tag/email/'>email</a>, <a href='http://vodoom.wordpress.com/tag/fetchmail/'>fetchmail</a>, <a href='http://vodoom.wordpress.com/tag/gmail/'>gmail</a>, <a href='http://vodoom.wordpress.com/tag/procmail/'>procmail</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/324/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/324/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/324/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=324&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2010/02/09/making-a-backup-of-my-gmail-account-with-fetchmail-and-procmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>virtualbox: setting up 1680&#215;1050 screen resolution</title>
		<link>http://vodoom.wordpress.com/2009/11/18/virtualbox-setting-up-1680x1050-screen-resolution/</link>
		<comments>http://vodoom.wordpress.com/2009/11/18/virtualbox-setting-up-1680x1050-screen-resolution/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 16:39:36 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[virtualbox]]></category>
		<category><![CDATA[xorg]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=305</guid>
		<description><![CDATA[I still cannot believe that I spent 8 hours trying out to setup this screen size under virtualbox &#8230; ok some context first. I am using vmware for 3 years at work (in my two previous jobs), and I must say it worked flawlessly all this time. But lately it started to &#8220;freeze&#8221; when compiling [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=305&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">
I still cannot believe that I spent 8 hours trying out to setup this screen size under virtualbox &#8230;</p>
<p>ok some context first.</p>
<p>I am using vmware for 3 years at work (in my two previous jobs), and I must say it worked flawlessly all this time.</p>
<p>But lately it started to &#8220;freeze&#8221; when compiling some hot stuff under the vm. It also became more and more a resource hog.</p>
<p>So I started to look for some alternatives, and of course virtualbox from sun showed up. I gave it a try and was hooked up: it is fast, and handled very well the various OS and jobs I throwed at it.</p>
<p>So I thought it is ready to replace vmware at work (and it is, with some more work).</p>
<p>I use a windows box (for corporate reasons etc.), and edit/compile code in virtualbox vm running opensolaris (for efficiency reasons :-)). The changes I make are later on compiled on build machine.</p>
<p>I use a X display fo 1680&#215;1050 32 bpp &#8211; and yes took me some time to get this setup on vmware.</p>
<p>I wanted to have the same setup on virtualbox and &#8230; At first I failed: virtualbox gfx card did not have the VESA mode I wanted and defaulted to 1280&#215;1024, with a lot of unused space left on my monitor :-(</p>
<p>I finally found a solution, and I am posting it here so I will not forget it later on: I used VBoxManage &#8211; read the section &#8220;custom VESA modes&#8221; in the virtualbox user manual.</p>
<p>On your windows box, lauch the command line prompt and go to the folder where virtualbox has been installed, in my case:</p>
<p><code>C:\Program Files\Sun\VirtualBox</code></p>
<p>then add the missing VESA mode fro your vm, in my case the vm is called &#8221;adam&#8221;:</p>
<p><code>VBoxManage setextradata "adam" "CustomVideoMode1" "1680x1050x32"</code></p>
<p>Restart your vm and *magic* my login screen is 1680&#215;1050.</p>
<p>Do not forget to edit your xorg.conf file to actually setup this mode. Here is mine in case you need an example (this is a valid file for samsung monitor model 2243bw, for other monitors you MUST edit the HorizSync/VertRefresh values or comment them out) :</p>
</div>
<p><code> Section "Monitor"<br />
Identifier  "samsung-2243bw"<br />
HorizSync   30-81<br />
VertRefresh 50-85<br />
Modeline "1680x1050"  147.14  1680 1784 1968 2256  1050 1051 1054 1087  -HSync +Vsync<br />
EndSection<br />
Section "Screen"<br />
Identifier  "Screen 1"<br />
Monitor     "samsung-2243bw"<br />
DefaultDepth 24<br />
Subsection "Display"<br />
Depth       8<br />
Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"<br />
ViewPort    0 0<br />
EndSubsection<br />
Subsection "Display"<br />
Depth       16<br />
Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"<br />
ViewPort    0 0<br />
EndSubsection<br />
Subsection "Display"<br />
Depth       24<br />
Modes       "1680x1050" "1280x1024" "1024x768" "800x600" "640x480"<br />
ViewPort    0 0<br />
EndSubsection<br />
EndSection<br />
Section "ServerLayout"<br />
Identifier  "Simple Layout"<br />
Screen "Screen 1"<br />
EndSection<br />
Section "InputDevice"<br />
Identifier  "VBoxMouse"<br />
Driver      "vboxmouse"<br />
Option      "CorePointer"<br />
EndSection</code></p>
<p>Enjoy and share.</p>
<br />Posted in configuration, OS Tagged: opensolaris, virtualbox, xorg <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/305/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/305/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/305/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=305&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2009/11/18/virtualbox-setting-up-1680x1050-screen-resolution/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>xvid on opensolaris</title>
		<link>http://vodoom.wordpress.com/2009/05/06/xvid-on-opensolaris/</link>
		<comments>http://vodoom.wordpress.com/2009/05/06/xvid-on-opensolaris/#comments</comments>
		<pubDate>Wed, 06 May 2009 06:04:28 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[multi-media]]></category>
		<category><![CDATA[nasm]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[xvid]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=264</guid>
		<description><![CDATA[trying to compile xvid on opensolaris &#8230; why compiling it !? I am actually interested to build mplayer on opensolaris, with xvid and x264 support. First things first: download mplayer sources from their website, they have an svn repository one can use to download the latest version: $ svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer If you do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=264&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>trying to compile xvid on opensolaris &#8230;</h2>
<h3>why compiling it !?</h3>
<p>I am actually interested to build mplayer on opensolaris, with xvid and x264 support.</p>
<p>First things first: download mplayer sources from their website, they have an svn repository one can use to download the latest version:</p>
<pre>$ svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer</pre>
<p>If you do not have subversion, try to install it using the following command:</p>
<pre>$ pfexec pkg install SUNWsvn</pre>
<p>you should have now a directory called mplayer, it has the sources we want in there. Mplayer uses the GNU autotools, let&#8217;s configure the sources:</p>
<pre>
$ ./configure
Detected operating system: SunOS
Detected host architecture: i386
Checking for gcc version ... 3.4.3
Checking for host cc ... gcc
Checking for cross compilation ... no
Checking for CPU vendor ... AuthenticAMD (15:107:2)
Checking for CPU type ...  AMD Athlon(tm) 64 X2 Dual Core Processor 4200+
Checking for kernel support of mmx ... yes
Checking for kernel support of mmxext ... yes
Checking for kernel support of 3dnow ... yes
Checking for kernel support of 3dnowext ... yes
Checking for kernel support of sse ... yes
Checking for kernel support of sse2 ... yes
Checking for kernel support of cmov ... yes
Checking for mtrr support ... yes
Checking for GCC &amp; CPU optimization abilities ... k8
Checking for byte order ... little-endian
...
...
Config files successfully generated by ./configure  !

Install prefix: /usr/local
Data directory: /usr/local/share/mplayer
Config direct.: /usr/local/etc/mplayer

Byte order: little-endian
Optimizing for: k8

Languages:
Messages/GUI: en
Manual pages: en

Enabled optional drivers:
Input: dvdnav(internal) ftp tv libdvdcss(internal) dvdread(internal) vcd smb network
Codecs: libavcodec(internal) qtx xanim win32 faad2(internal) libmpeg2(internal) liba52(internal) mp3lib(internal) speex tremor(internal)
Audio output: sdl mpegpes(file)
Video output: sdl pnm jpeg png mpegpes(file) cvidix yuv4mpeg md5sum tga
  Disabled optional drivers:
    Input: vstream pvr radio tv-teletext tv-v4l2 tv-v4l1 tv-dshow live555 nemesi cddb cdda dvb
    Codecs: libschroedinger libdirac x264 xvid libdv libamr_wb libamr_nb real faac musepack libdca libtheora toolame twolame libmad liblzo gif
    Audio output: sun alsa openal jack pulse nas esd arts oss v4l2 ivtv dxr2
    Video output: zr zr2 v4l2 ivtv dxr3 dxr2 vesa gif89a fbdev svga caca aa ggi xmga mga xvidix winvidix opengl 3dfx dga vdpau xvmc xv x11 dfbmga directfb bl xvr100 tdfx_vid wii s3fb tdfxfb
</pre>
<p>Hum, not so good. The summary says we are missing a bunch of codecs I am interested in: x264 xvid libtheora.<br />
Some output drivers are also missing: xv x11 opengl.</p>
<p>I am so used to get mplayer from linux that I almost forgot how it was to build everything from source &#8230;<br />
But there also some good things about that: I will bee able to have some tweaking for my cpu (at least that&#8217;s my hope).</p>
<h2>compiling xvid</h2>
<p>So now, we need to get the missing codecs/drivers and compile them so mplayer can use them. First let&#8217;s get xvid:</p>
<pre>$ wget http://downloads.xvid.org/downloads/xvidcore-1.2.1.tar.gz</pre>
<p>Using the SUN compiler to compile xvid is not supported, from the FAQ:</p>
<blockquote><p>    Q: Are there instructions available how to compile Xvid with my compiler?<br />
    A: Have a look at the install readme file that comes along with Xvid. It describes how to use the Xvid build scripts to compile Xvid with gcc under Linux or MinGW/CygWin. Xvid can also be compiled with Microsoft Visual C++ compiler using the provided project files included in the build directory. For other compilers you’re pretty much on your own. It should be not very difficult however to make the code compile with a different compiler.</p></blockquote>
<p>Ok so let&#8217;s try it, otherwise why having the source code :-) ?</p>
<h3>compiler to be used</h3>
<p>The compiler that I want to use is the sun compiler, version on my opensolaris box:</p>
<pre>
    $ cc -V
    cc: Sun Ceres C 5.10 SunOS_i386 2009/03/06
    usage: cc [ options] files.  Use 'cc -flags' for details
</pre>
<h3>assembler to be used for xvid</h3>
<p>If available, I want to use assembly code provided by xvid. xvid uses nasm to assemble the code. Time to get it:</p>
<pre>$ wget http://www.nasm.us/pub/nasm/releasebuilds/2.06rc11/nasm-2.06rc11.tar.gz</pre>
<p>then we compile and install it:</p>
<pre>
    $ gtar xzf nasm-2.06rc11.tar.gz
    $ cd nasm-2.06rc11
    $ CC=/usr/bin/suncc CFLAGS='-xtarget=native' ./configure
    checking for prefix by checking for nasm... /usr/local/bin/nasm
    checking for gcc... /usr/bin/suncc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... yes
    ...
</pre>
<p>Note that the compiler used is suncc, the c compiler from sun and <b>not</b> gcc.<br />
When compiling some warnings are given:</p>
<pre>cc: Warning: illegal option -d=c99</pre>
<p>For now I will ignore them &#8211; the option was dropped anyway. It&#8217;s now time to install nasm:</p>
<pre>
    $ pfexec make install
    mkdir -p /usr/local/bin
    /usr/bin/ginstall -c nasm /usr/local/bin/nasm
    /usr/bin/ginstall -c ndisasm /usr/local/bin/ndisasm
    mkdir -p /usr/local/share/man/man1
    /usr/bin/ginstall -c -m 644 ./nasm.1 /usr/local/share/man/man1/nasm.1
    /usr/bin/ginstall -c -m 644 ./ndisasm.1 /usr/local/share/man/man1/ndisasm.1
</pre>
<p>cool, now let&#8217;s go back to xvid.</p>
<h3>tweaking the xvid source</h3>
<p>Since I want to be able to work on this source tree from time to time, I&#8217;ll track this directory content using mercurial.</p>
<pre>
    $ hg init
    $ hg add
</pre>
<p>let&#8217;s give it a first try, let&#8217;s go to the build directory:</p>
<pre>
    $ cd build/generic
    $ CC=/usr/bin/suncc CFLAGS='-xtarget=native' ./configure
    ....
    $ make
    make: Fatal error in reader: Makefile, line 82: Badly formed macro assignment
</pre>
<p>So &#8230; chances are that we have a gnu makefile here:</p>
<pre>
gmake
  D: =build
  C: ./decoder.c
"../../src/portab.h", line 439: warning: no explicit type given
"../../src/portab.h", line 439: syntax error before or at: void
"../../src/portab.h", line 447: warning: no explicit type given
"../../src/portab.h", line 447: syntax error before or at: int64_t
"../../src/global.h", line 63: warning: no explicit type given
"../../src/global.h", line 63: syntax error before or at: int
"../../src/global.h", line 70: warning: no explicit type given
"../../src/global.h", line 70: syntax error before or at: int
"../../src/global.h", line 234: warning: no explicit type given
"../../src/global.h", line 234: syntax error before or at: uint32_t
"../../src/image/image.h", line 41: cannot have void object: __inline
"../../src/image/image.h", line 42: syntax error before or at: image_null
</pre>
<p>It was a gnu makefile, hence gmake took care of it. The source files use some gcc extension, like __inline. There is a c99 keyword for it, that does pretty much the same thing: inline.<br />
We reconfigure the package:</p>
<pre>
$ CC=/usr/bin/suncc CFLAGS='-D__inline=inline -xtarget=native' ./configure
</pre>
<p>hum &#8230; Too many warnings:</p>
<pre>
"../../src/encoder.c", line 1085: warning: integer overflow detected: op "&lt;&lt;"
"../../src/encoder.c", line 1112: warning: integer overflow detected: op "&lt;&lt;"
"../../src/encoder.c", line 1150: warning: integer overflow detected: op "&lt;&lt;"
...
"../../src/xvid.c", line 105: warning: assignment type mismatch:
	pointer to void "=" pointer to function(int) returning void
...
"../../src/bitstream/mbcoding.c", line 1848: warning: initializer will be sign-extended: -1
"../../src/bitstream/mbcoding.c", line 1859: warning: initializer will be sign-extended: -1
"../../src/bitstream/mbcoding.c", line 1895: warning: initializer will be sign-extended: -1
...
</pre>
<p>overflow is scary &#8230; I&#8217;ll need to check the code and see whats going on.</p>
<p>The linker problem can be solved by installing the following patch found <a href="http://opensolaris.org/jive/thread.jspa?messageID=323692">here</a>.</p>
<p><b>Edit from May 13th 2009</b>: I finally added a patch for SUN compiler to get xvid to compile without too many warnings, you can find it <a href="http://gist.github.com/111024">here</a></p>
<br />Posted in programming, unix Tagged: c, multi-media, nasm, opensolaris, xvid <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/264/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/264/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/264/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=264&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2009/05/06/xvid-on-opensolaris/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>migrating data from linux to opensolaris and zfs with a mirror setup</title>
		<link>http://vodoom.wordpress.com/2009/04/05/migrating-data-from-linux-to-opensolaris-and-zfs-with-a-mirror-setup/</link>
		<comments>http://vodoom.wordpress.com/2009/04/05/migrating-data-from-linux-to-opensolaris-and-zfs-with-a-mirror-setup/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 04:58:13 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[storage]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[opensolaris]]></category>
		<category><![CDATA[zfs]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=229</guid>
		<description><![CDATA[What I am trying to do I am trying to backup my data (music, movies, my companies files, perso data) to a stable storage location with some mirroring &#8211; I have commodity hardware like most you guys have &#8211; I am not willing to loose them because of a faulty hardware. Right now I have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=229&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>What I am trying to do</strong><br />
I am trying to backup my data (music, movies, my companies files, perso data) to a stable storage location with some mirroring &#8211; I have commodity hardware like most you guys have &#8211; I am not willing to loose them because of a faulty hardware.<br />
Right now I have on my main box 2&#215;1.5TB disks for storage and a root disk of 200GB, used for my different operating systems (linux, opensolaris and DragonflyBsd).<br />
I bought the 2nd 1,5TB to backup my main 1.5TB disk (hence this article ;-) ).</p>
<p><strong>Why choosing Hard drive storage</strong><br />
I ruled out dvd/cd backups because:</p>
<ul>
<li> too much data to back-up (more than one TB), taking of that many disks brings in other problems (like space &#8230;). I am a backup junky, I backup everything and multiple times :-(</li>
<li>MTBF of burned dvd/cd <strong>can</strong> be very low (at least the discs I buy &#8230;), see this <a href="http://forums.cnet.com/5208-7588_102-0.html?forumID=70&amp;threadID=327942&amp;messageID=2968199" target="_blank">faq</a> to understand how variable the life of a burned dvd is and this <a href="http://forums.cnet.com/5208-7588_102-0.html?forumID=70&amp;threadID=327942&amp;messageID=2968199" target="_blank">thread</a> that confirm my past experience with burned cd/dvd (I lost 5 out of 100 cd after 4 years).</li>
<li>regularly checking for damaged dvd is time consuming: I am not willing to spend hours/days flipping disks around to see if all my collection is ok. The machine can do that on my behalf with hard disks (zfs scrub command or manual md5sums to compare both disks to the original md5sum stored somewhere &#8211; hardcore but still easier than manually feeding my dvd toaster &#8230;)</li>
</ul>
<p><strong>Why zfs</strong><br />
I am a long time user of the <a href="http://en.wikipedia.org/wiki/XFS" target="_blank">xfs</a> filesystem: everytime I setup a linux box, this is the filesystem I use (except for /boot, I use ext2). Of course xfs does not provide mirroring or raid out of the box, but it is a very reliable filesystem.<br />
As for <a href="http://en.wikipedia.org/wiki/ZFS" target="_blank">zfs</a>, I was impressed by this <a href="http://blogs.sun.com/elowe/entry/zfs_saves_the_day_ta" target="_blank">article</a> from <a href="http://blogs.sun.com/elowe/" target="_blank">eric lowe&#8217;s blog</a>. After that I was curious, my main issue with storage is how to prevent <a href="http://pogue.blogs.nytimes.com/2009/03/26/should-you-worry-about-data-rot/?apage=3" target="_blank">data rot</a>. There are no perfect solution, but zfs is a nice step in the right direction; I like this quote (see the <a href="http://www.sun.com/bigadmin/content/submitted/data_rot.jsp" target="_blank">article</a>) from Kevin McAleer, as it sums up perfectly why I did choose zfs:</p>
<blockquote><p>Finally, I choose to use the ZFS file system because I know that it checksums every read and write to the filing system, ensuring that my data is as it was when it was written to disk.</p></blockquote>
<p>The nice plus is that it has some very nice documentation like <a href="http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide" target="_blank">this one</a> from <a href="http://www.solarisinternals.com/" target="_blank">solaris internals</a>.</p>
<p><strong>why mirroring instead of a raid configuration</strong><br />
That&#8217;s the simplest setup, easy to understand, easy to maintain, easy to export since each disk is complete as opposed to raid. I don&#8217;t think a mirror is better than a raid setup: it just suits my needs better than a raid would do (at least for now).<br />
An alternate configuration, a raid setup is described <a href="http://www.sun.com/bigadmin/content/submitted/zfs_mac_os.x.jsp" target="_blank">here</a>.</p>
<p><strong>Why opensolaris</strong><br />
I use open technologies/standards and open source code in general for as many things as I can. I try to avoid any vendor lock-in and I do not trust any software that does not have its code available and that I can rebuild (yes I probably have paranoia).<br />
Linux meet these requirements as well as <a href="http://www.opensolaris.org/" target="_blank">opensolaris</a> (even better though), so why solaris in the end ? Mainly because zfs is part of it natively. Linux has a zfs port available, through fuse, but it has performance issues.<br />
<a href="http://www.freebsd.org/" target="_blank">FreeBSD</a> was serious candidate, I hesitated a long time between opensolaris and FreeBSD &#8230;<br />
I am a unix developer, I use c and c++, opensolaris has the gcc tool chain as FreeBSD has and also the <a href="http://developers.sun.com/sunstudio/" target="_blank">sun studio</a> compilers that I have to use from time to time for my day to day job &#8230;<br />
A totaly arbitray choice for some of you, I know, but this is my setup :-).</p>
<p><strong>Seting up the box for opensolaris and zfs</strong><br />
First things first: dowloading opensolaris, I choosed the <a href="http://dlc.sun.com/osol/opensolaris/2008/11/osol-0811-global.iso" target="_blank">2008/11 version for 32/64 bits</a>.<br />
I installed it on my box without any major issue. Instalation instructions can be found at the sun website <a href="http://dlc.sun.com/osol/docs/content/2008.11/getstart/sliminstall.html" target="_blank">here</a>.<br />
I said no major issues, I did not say no issues at all ;-)</p>
<ul>
<li> I run linux, when I installed opensolaris I found out that it wiped out my mbr, and I was not able to choose to boot linux. No big deal for me: I went to the grub console and booted it from here; I then updated grub and reinstalled it. This can be a little bit too complicated if you are not used to this kind of dance, so do as the doc says:</li>
</ul>
<blockquote><p><strong>Note &#8211; </strong><em>Before you install the OpenSolaris OS on a system that is running the Linux OS, save a copy of the </em><tt>menu.lst</tt><em> file. The contents of the GRUB </em><tt>menu.lst</tt><em> file dictate what is displayed in the GRUB menu when you boot the system. You will need to update the GRUB menu after the installation. For further information, see </em><tt>menu.lst</tt> file specifics at <a href="http://docs.sun.com/app/docs/doc/819-2379/hbx86boot-68676?a=view" target="_blank">x86: Booting a Solaris System with GRUB</a><em>.</em></p></blockquote>
<ul>
<li>disk partitioning did not work under the installer for my disks. I ended up using fdisk by hand: I dedicated a full primary partition to solaris with fdisk, and that was it.</li>
</ul>
<p>I choosed to use zfs for the whole disk, as such when booting into solaris:</p>
<blockquote>
<pre>ppi@leo:~$ zpool list
NAME      SIZE   USED  AVAIL    CAP  HEALTH  ALTROOT
rpool      54G  10.1G  43.9G    18%  ONLINE  -</pre>
</blockquote>
<p>will show you the rpool, the root zfs pool which is where / is mounted. So far so good, now we need to setup our storage policy: the zfs mirror.</p>
<p><strong>listing the storage devices</strong><br />
The first step is to create a &#8216;pool&#8217; i.e. a storage pool. Members of the pool are devices, hard disks. Current devices one the system can be listed using the &#8216;format&#8217; command:</p>
<blockquote>
<pre>root@leo:/root# format
Searching for disks...

The device does not support mode page 3 or page 4,
or the reported geometry info is invalid.
WARNING: Disk geometry is based on capacity data.

The current rpm value 0 is invalid, adjusting it to 3600

The device does not support mode page 3 or page 4,
or the reported geometry info is invalid.
WARNING: Disk geometry is based on capacity data.

The current rpm value 0 is invalid, adjusting it to 3600

The device does not support mode page 3 or page 4,
or the reported geometry info is invalid.
WARNING: Disk geometry is based on capacity data.

The current rpm value 0 is invalid, adjusting it to 3600
done

c7t2d0: configured with capacity of 1397.21GB
c7t5d0: configured with capacity of 1397.21GB
c9t0d0: configured with capacity of 465.74GB

AVAILABLE DISK SELECTIONS:
       0. c7t0d0
          /pci@0,0/pci1458,b002@11/disk@0,0
       1. c7t2d0
          /pci@0,0/pci1458,b002@11/disk@2,0
       2. c7t5d0
          /pci@0,0/pci1458,b002@11/disk@5,0
       3. c9t0d0
          /pci@0,0/pci1458,5004@13,2/storage@3/disk@0,0
Specify disk (enter its number):</pre>
</blockquote>
<p>This will list the devices available on your system. for example, my two 1,5TB disks are c7t2d0 and c7t5d0. How do I know that ? At the prompt I selected c7t2d0 by selecting 1:</p>
<pre>selecting c7t2d0
[disk formatted]
No Solaris fdisk partition found.

FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !     - execute , then return
        quit
format&gt; inquiry
Vendor:   ATA
Product:  ST31500341AS
Revision: SD1B</pre>
<p>I did the same thing for the second disk:</p>
<pre>format&gt; disk 2
selecting c7t5d0
[disk formatted]
No Solaris fdisk partition found.
format&gt; inquiry
Vendor:   ATA
Product:  ST31500341AS
Revision: CC3G</pre>
<p><strong>setting up the zpool and creating filesystems</strong><br />
Now we know which disks should be part of the mirror pool: c7t5d0 and c7t2d0.<br />
We can go on and create the pool &#8230; well no we cannot. one of the 1,5TB drives is formatted as XFS and contains the data to be mirrored, we cannot setup the pool as a mirror for now. We need to migrate the data to the other disk, reformat this one as zfs, since opensoalris don&#8217;t know how to handle xfs and then setup the mirror.<br />
Hopefully setting up the mirror after this initial copy is very easy with zfs. So for now we create a regular zfs pool with one drive only:</p>
<pre>zpool create tank c7t5d0p0</pre>
<p>This will create the zpool &#8216;tank&#8217; and add device c7t5d0p0 to it.<br />
We need now to create a zfs filesystem on it:</p>
<pre>zfs create tank/media
...
zfs create tank/backup
...</pre>
<p>tank/media will store all my multimedia files and tank/backup will store all my other files, like digital personal data, copy of the invoices made to my clients, my emails &#8230;<br />
These filesystems are mounted on /, so you can easily access them using /tank/media and /tank/backup.</p>
<p>We are now ready to start the migration of the linux data to opensolaris/zfs.</p>
<p><strong>Migrating the data from linux to solaris</strong><br />
The linux system is installed on the same box, that rules out networking to replicate the data. As such I will have to use another disk, a smaller disk to migrate the data from linux to opensolaris.<br />
A usb disk of 320 GB will do the trick (i have a spare disk and an usb enclosure so &#8230;).</p>
<p>Now the real thing: we need to have linux and opensolaris to be able to exchange data and as such they need to mount/unmount the same filesystem&#8230; And off course they do not share any reliable filesystem (I mean a reliable implementation), there are patches/software to access ntfs and ext2 filesystem.I tried them and the machine hang the various times I used them.</p>
<p>I checked then the zfs implementation for linux, expecting the same overall quality as the ext2 and ntfs filesystems.<br />
I must say that I was surprised to come upon a very stable <a href="http://www.wizy.org/wiki/ZFS_on_FUSE">zfs port for linux</a> (I downloaded the trunk version, not the 0.4 which has some bugs).</p>
<pre>	hg clone http://www.wizy.org/mercurial/zfs-fuse/trunk
	cd trunk/src
	scons
	sudo scons install</pre>
<p>Do not forget to add /usr/local/bin to your PATH variable so you can type:</p>
<pre>	sudo zfs-fuse</pre>
<p>That will initialize the zfs code for linux. You can now use zfs commands under linux :-)</p>
<pre>zpool create tempdev /dev/sdd
...
zfs create tempdev/mass
...</pre>
<p>And then copy from the 1.5TB to the 320 GB &#8211; while you grab a coffe. It take sometime, but I do not care: the machine is working, not me.</p>
<p>It worked quite well, minus the performance &#8211; 10 MB/s at best &#8211; anyhow it was good enough for my purpose: migrating my data from linux to opensolaris.</p>
<p>Once you finished the copy from linux, we need to copy it to opensolaris. We need to find the usb drive and mount the linux zfs filesystem. To check, under opensolaris, where is the zfs pool you created under linux, run the command &#8216;zpool import&#8217;:</p>
<pre>root@leo:~# zpool import
  pool: tempdev
    id: 13948735862038308700
 state: ONLINE
status: The pool is formatted using an older on-disk version.
action: The pool can be imported using its name or numeric identifier, though
	some features will not be available without an explicit 'zpool upgrade'.
config:

	tempdev     ONLINE
	  c9t0d0p0  ONLINE</pre>
<p>It&#8217;s like Magic. ZFS complains about the version of zfs used to create the pool, but we don&#8217;t care, it can handle it.<br />
To add the pool to the system, we try to run (see the doc):</p>
<pre>zpool import tempdev</pre>
<p>If that doesn&#8217;t work, try with the -f option.<br />
At this point you are now able to copy your +300GB data to the new 1,5 TB disk of yours.</p>
<p>I did this all dance i.e. copy/erase/import/copy a bunch of time. I was not in a hurry &#8211; I wanted a functionnal mirror and had some time available to play with zfs.</p>
<p><strong>add mirroring to the pool</strong><br />
Once all the data has been copied over, it&#8217;s time to setup the mirroring i.e. using the second 1,5TB to be a replica. This is the easiest part, you just have to add this new device (you need to remove all partitions from it before) :</p>
<pre>zpool attach tank c7t5d0p0 c7t2d0p0</pre>
<p>where c7t5d0p0 is the tank disk that already exists and c7t2d0p0 is the new disk to be added to the pool. The pool will automatically be promoted to a mirror, and zfs will start re-silvering the disk i.e. copying data to the replica.</p>
<p>Dead simple. I loved it &#8211; the culmination of the whole thing :-)</p>
<p>You can check the state of the pool with &#8216;zpool status tank&#8217;, when it is finished you will have:</p>
<pre>root@leo:~# zpool status tank
  pool: tank
 state: ONLINE
 scrub: none requested
config:

	NAME          STATE     READ WRITE CKSUM
	tank          ONLINE       0     0     0
	  mirror      ONLINE       0     0     0
	    c7t5d0p0  ONLINE       0     0     0
	    c7t2d0p0  ONLINE       0     0     0

errors: No known data errors</pre>
<p>Quit a journey: a long but easy ride.<br />
ZFS fits perfectly in my new setup, I can now go to sleep happy since I know my data is in good hands. One can do many. many more things with it, I barely scratched the surface and only cared about my immediate needs: having a set of working and trusted mirrored disks :-).</p>
<p>Share, and enjoy.</p>
<br />Posted in storage, unix Tagged: migration, opensolaris, unix, zfs <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/229/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/229/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/229/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=229&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2009/04/05/migrating-data-from-linux-to-opensolaris-and-zfs-with-a-mirror-setup/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>const variable, const pointer and invalid const assignment in c++</title>
		<link>http://vodoom.wordpress.com/2009/03/27/const-variable-cont-pointers-and-invalid-const-assignment-in-c/</link>
		<comments>http://vodoom.wordpress.com/2009/03/27/const-variable-cont-pointers-and-invalid-const-assignment-in-c/#comments</comments>
		<pubDate>Fri, 27 Mar 2009 07:14:01 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[cpp]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=193</guid>
		<description><![CDATA[This something that regularly shows up when discussing const correctness of a c++ piece of code: see wikipedia const correctness entry, the c++ faq light section 18 and herb sutter item #6. I wrote this after someone asked me why cont int** cannot be assigned an int**, which seemed a valid conversion. I pointed him [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=193&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This something that regularly shows up when discussing const correctness of a c++ piece of code: see wikipedia const correctness <a href="http://en.wikipedia.org/wiki/Const_correctness">entry</a>, the c++ faq light <a href="http://www.parashift.com/c++-faq-lite/const-correctness.html">section 18</a> and herb sutter item <a href="http://gotw.ca/gotw/006.htm">#6</a>.</p>
<p>I wrote this after someone asked me why cont int** cannot be assigned an int**, which seemed a valid conversion. I pointed him to the c++ faq like, section 18 item 17, but It was pretty terse:</p>
<blockquote><p>The reason the conversion from Foo** → const Foo** is dangerous is that it would let you silently and accidentally modify a const Foo object without a cast:<br />
<code><br />
class Foo {<br />
public:<br />
void modify();  // make some modify to the this object<br />
};</code><br />
<code><br />
int main()<br />
{<br />
const Foo x;<br />
Foo* p;<br />
const Foo** q = &amp;p;  // q now points to p; this is (fortunately!) an error<br />
*q = &amp;x;             // p now points to x<br />
p-&gt;modify();         // Ouch: modifies a const Foo!!<br />
...<br />
}<br />
</code></p>
</blockquote>
<p>It was hard for him to see why such thing was possible, after all, int* to a const int* is a valid assignment.</p>
<p>If you are comfortable with the const keyword, go directly to the &#8220;<strong>messing with it</strong>&#8221; section :-)</p>
<p>OK for now let&#8217;s go back to the const keyword itself: it allows a c++ object to be considered as read-only (well, almost &#8230;).<br />
The various code snippets were compiled/tested with:<br />
<code><br />
linuxbox:~$ c++ --version<br />
c++ (Ubuntu 4.3.2-1ubuntu12) 4.3.2<br />
...<br />
</code></p>
<h2>syntax first</h2>
<p>Most of the confusion when using this keyword comes from how c++ declares variable, the syntax used: machine friendly but definitely not human friendly.</p>
<p>Easy things first:<br />
<code><br />
const int one = 1;<br />
const char letter_a = 'a';<br />
</code></p>
<p>These declaration are straight forward, let&#8217;s raise the bar:<br />
<code><br />
const int *p = &amp;one;<br />
const int two = 2;<br />
p = &amp;two;<br />
</code><br />
so far so good: p is pointer to a const int. Both addresses of one and two can be assigned to p. Of course the following is not allowed, since p points to a read-only int:<br />
<code><br />
p = &amp;one;<br />
*p = 2; /* error - pointed object cannot be changed */<br />
</code><br />
now let&#8217;s have:<br />
<code><br />
const int * const p = &amp;one;<br />
</code><br />
now p is a pointer to a const int plus p is read-only too:<br />
<code><br />
p = &amp;two; /* error: p cannot be changed */<br />
</code><br />
g++ diagnostic is:<br />
<code><br />
linuxbox:~$ c++ const.cpp<br />
const.cpp: In function ‘int main()’:<br />
const.cpp:11: error: assignment of read-only location ‘* p’<br />
</code><br />
Note how the second const is declared <strong>after</strong> the star to qualify p as being const it self. This is the trick when reading const declaration (oh and yes, const int one = 1; and int const one = 1; are the same declarations), the star is used as a separator to whom the const is applied to.</p>
<p>We can promote a regular object to a const one:<br />
<code><br />
int a = 1;<br />
int* p = &amp;a;<br />
const int* q = p; // a cannot be modified through q<br />
</code></p>
<h2>messing with it</h2>
<p>Now it&#8217;s time to get ugly,  the following promotion won&#8217;t work:<br />
<code><br />
const int a = 1;<br />
int *p = 0;<br />
const int ** err = &amp;p;<br />
</code><br />
g++ diagnostic is:<br />
<code><br />
linuxbox:~$ c++ const.cpp<br />
const.cpp: In function ‘int main()’:<br />
const.cpp:20: error: invalid conversion from ‘int**’ to ‘const int**’<br />
</code><br />
and we are like &#8220;ugh ?&#8221;. And yes, it is very fortunate that the compiler can catch that&#8230;<br />
Why ? Otherwise we could change const objects and have undefined behavior without realizing it. Let&#8217;s say the previous example is legal:<br />
<code><br />
const int a = 1;<br />
int *p = 0;<br />
const int ** err = &amp;p;<br />
/* chaos from here */<br />
*err = &amp;a;<br />
*p = 2;<br />
</code></p>
<p>The type of *err is const int*, hence this assignment is legal:<br />
<code>*err = &amp;a;</code></p>
<p>and we know that <code>err = &amp;p;</code>, and that as such <code>*err == p</code> &#8230;<br />
So we have <code>*err == p</code> and <code>*err = &amp;a</code>, two different types&#8230;</p>
<p>Trying to change the value of a through err won&#8217;t work, err has the right type:<br />
<code>**err = 2 /* failure: err is const int**, it cannot change a */</code><br />
BUT we can do it through p now, p has the right type and the promotion allowed us to make it point to the const int a:<br />
<code>*p = 2; /* legal: p has the right type, we lost the trace of constness of a */</code><br />
We just allowed p to point to const int a and short circuit the type system.</p>
<p>That&#8217;s why this type of conversion is not allowed: we don&#8217;t want to be able to write such thing without the c++ type system catching it. Now go grab a coffee, you deserve it ;-)</p>
<p>Enjoy and share ;-)</p>
<br />Posted in programming Tagged: cpp <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=193&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2009/03/27/const-variable-cont-pointers-and-invalid-const-assignment-in-c/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>setting up my workstation: tweaking firefox, mutt and vim</title>
		<link>http://vodoom.wordpress.com/2008/12/28/setting-up-my-workstation-tweaking-firefox-mutt-and-vim/</link>
		<comments>http://vodoom.wordpress.com/2008/12/28/setting-up-my-workstation-tweaking-firefox-mutt-and-vim/#comments</comments>
		<pubDate>Sun, 28 Dec 2008 01:15:56 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[mutt]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=112</guid>
		<description><![CDATA[updated: Feb 17th, 2009 &#8211; added shell section updated: Feb 18th, 2009 &#8211; added picnick firefox extension updated: Dec 1st, 2009 &#8211; added firefox tweak for session store Each time I start a new contract or job, I go through the very same ritual: I spend some time tweaking my workstation. This is a really [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=112&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>updated: Feb 17th, 2009 &#8211; added shell section</strong></p>
<p><strong>updated: Feb 18th, 2009 &#8211; added picnick firefox extension</strong></p>
<p><strong>updated: Dec 1st, 2009 &#8211; added firefox tweak for session store<br />
</strong></p>
<p>Each time I start a new contract or job, I go through the very same ritual: I spend some time tweaking my workstation.</p>
<p>This is a really boring process, and it takes a lot of energy every-time I do it. This is because I spend too much time doing it by heart, instead of having my tweaks written somewhere I could re-use them (I now have a plain old tar file that I untar on my new workstation every time I get a new contract).</p>
<p>This post should fix this.</p>
<p>Here are my configuration files, firefox tweaks and other tips when I setup my work environment.</p>
<h3>shell environment</h3>
<p>I don&#8217;t really care which shell is available, but I try to make sure that <a href="http://www.gnu.org/software/screen/">screen</a> is there. If not, I try to install it ASAP. I have a really simple .screenrc file:</p>
<pre>        # terminfo and termcap for nice 256 color terminal
        # tell screen how to set colors. AB = background, AF=foreground
        termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'

        # erase background with current bg color
        defbce "on"

        # I need ths status line of screen - much easier to navigate and use
        hardstatus on
        hardstatus alwayslastline
        hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H
        %{..Y} %d/%m/%Y %C%a "</pre>
<p>I have a very simple shell rc file, currently a .bashrc:</p>
<pre>        # yes I use gpg, and by default this is the key that should be used
        export GPGKEY=E495D229

        # I am a bit fanatic on what my prompt should lokks like
        function jobcount {
            jobs | wc -l | tr -d " "
        }
        export PS1='$(jobcount):\u@\h:\w\$ '

        # less is much better than more
        export PAGER=/usr/bin/less</pre>
<h3>text editor</h3>
<p><a href="http://www.vim.org">vim</a> is the editor I use, corresponding configuration file (~/.vimrc). From time to time I switch to plain old vi on some unix systems like IBM AIX or SUN SOLARIS, <a href="http://www.bostic.com/vi/">nvi</a> on BSDs or <a href="http://elvis.vi-editor.org/">elvis</a> on linux. I do switch to these editors when vim is configured in gui mode, and/or when  it is to slow to get a decent console mode.</p>
<p>My .vimrc file is <a href="http://vodoom.wordpress.com/configuration-files/vimrc/">here</a>. Its associated color scheme was inspired from <a href="http://www.vim.org/scripts/script.php?script_id=1464">moria</a> and adapted so it can be used in a 256 color terminal, this is <a href="http://vodoom.wordpress.com/configuration-files/moria256vim/">moria256</a>.</p>
<h3>email configuration</h3>
<p>I use the following email architecture:</p>
<ul>
<li><a href="http://www.mutt.org">mutt</a> as my <a href="http://en.wikipedia.org/wiki/Mail_user_agent">MUA</a>, powerful (regex friendly)</li>
<li><a href="http://fetchmail.berlios.de/">fetchmail</a> as my <a href="http://en.wikipedia.org/wiki/Mail_Transfer_Agent">MTA</a></li>
<li><a href="www.procmail.org/">procmail</a> as my <a href="http://en.wikipedia.org/wiki/Mail_delivery_agent">MDA</a></li>
</ul>
<p>corresponding configuration files are: <a href="http://vodoom.wordpress.com/configuration-files/muttrc/">muttrc</a>, <a href="http://vodoom.wordpress.com/configuration-files/fetchmailrc/">fetchmailrc</a> and <a href="http://vodoom.wordpress.com/configuration-files/procmailrc/">procmailrc</a>. The imap gmail configuration file is <a href="http://vodoom.wordpress.com/configuration-files/mutt-gmailconf/">here</a>.</p>
<p>So far this setup has been very solid, mutt is a gem. No smtp client there, I use mutt for now but may switch to exim in a near future (no <a href="http://email.about.com/library/weekly/aa082597.htm">dsn</a> with mutt for now).</p>
<h3>firefox extensions</h3>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/271">colorzilla</a>: pickup colors from any web page</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/2290">palette grabber</a>: creates a color palette from a web page</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/60">webdeveloper</a>: popular extension for web developers</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/219">foxytunes</a>: listen to music in firefox</p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/684">FireFTP</a>: add ftp navigation to firefox</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/3615">delicious</a>: bookmarks from any browser</p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/68">Dictionary Search</a>: provides a very easy way to look-up  (or translate) a word in a Web page or an email</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/1730">ScribeFire</a>: this is a full-featured blog editor that integrates with your browser and lets you easily post to your blog</p>
<p><a href="http://toolbar.google.com">google toolbar</a>: if you are a google user, I am sure you already know the infamous toolbar.<a href="http://toolbar.google.com"><br />
</a></p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/433">flashblock</a>: disallow flash to play automatically &#8211; a real time saver<br />
<a href="https://addons.mozilla.org/fr/firefox/addon/6349"></a></p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/8381">Evernote</a>: replacement of google reader since as 2009, development on it has been stopped.<a href="https://addons.mozilla.org/fr/firefox/addon/8381"><br />
</a></p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/7661">Read it later</a>: saves a web page so you can read it later on.<a href="https://addons.mozilla.org/fr/firefox/addon/7661"><br />
</a></p>
<p><a href="https://addons.mozilla.org/fr/firefox/addon/3006">download helper</a>: downloads any video from a web page</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/1689">pronounce</a>: how to pronounce a word</p>
<p><a href="https://addons.mozilla.org/en-US/firefox/addon/4889">picnick</a>: edit images with a right click</p>
<h3>firefox tweaks</h3>
<p><a href="http://kb.mozillazine.org/Browser.tabs.closeButtons">disable close button on tabs</a>: set to value 3</p>
<p><a href="http://kb.mozillazine.org/Network.prefetch-next">disable pre-fetching of web pages</a>: set to false</p>
<p><a href="http://kb.mozillazine.org/Browser.cache.memory.capacity">sets the amount of memory firefox should use</a>: set to 33 MB</p>
<p><a href="http://kb.mozillazine.org/Layout.spellcheckDefault">spellcheck every text area</a>: set to 2</p>
<p><a href="http://kb.mozillazine.org/Browser.urlbar.hideGoButton">turns off the rarely-used Go button at the end of the address bar</a>: set to true</p>
<p>set browser.sessionstore.interval to 300,000, see <a href="http://it.toolbox.com/blogs/bsd-guru/firefox-tip-35233?rss=1" target="_blank">dru lavigne post</a><em><a href="http://it.toolbox.com/blogs/bsd-guru/firefox-tip-35233?rss=1" target="_blank"></a></em> about it</p>
<br />Posted in configuration Tagged: firefox, mutt, screen, unix, vim <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=112&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2008/12/28/setting-up-my-workstation-tweaking-firefox-mutt-and-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
		<item>
		<title>Multi-core programming and design: tips and tricks</title>
		<link>http://vodoom.wordpress.com/2008/12/16/multi-core-programming-and-design-tips-and-tricks/</link>
		<comments>http://vodoom.wordpress.com/2008/12/16/multi-core-programming-and-design-tips-and-tricks/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 00:24:50 +0000</pubDate>
		<dc:creator>ppi</dc:creator>
				<category><![CDATA[concurency]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cpp]]></category>
		<category><![CDATA[multithread]]></category>

		<guid isPermaLink="false">http://vodoom.wordpress.com/?p=73</guid>
		<description><![CDATA[Multi-core programming is the new trend in software programming, the new big thing that will earn the big consulting companies the big bucks. Don&#8217;t get me wrong: I am not saying it&#8217;s a fad or something like that, I am just saying that it&#8217;s not something new at all, SMP machines exists for many years [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=73&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Multi-core" target="_blank">Multi-core</a> programming is the new trend in software programming, the new big thing that will earn the big consulting companies the big bucks.</p>
<p>Don&#8217;t get me wrong: I am not saying it&#8217;s a fad or something like that, I am just saying that it&#8217;s not something new at all, <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Symmetric_multiprocessing" target="_blank">SMP</a> machines exists for many<br />
years now.<br />
I started working with this kind of machine in 1997, a <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Silicon_Graphics" target="_blank">SGI</a> machine with 16 processors. Old stuff that becomes new stuff, again &#8230;<br />
Since then, when working for banking or financial companies, this has always been the motto: let&#8217;s do it faster. Add more ram, more cpus, more disks.<br />
And, yes please, use them as efficiently as possible: I paid the big bucks for the hardware, the software <strong>must</strong> use it  (Nowadays the companies willing to spend the most time and money on multi-core programming will probably be the gaming companies).</p>
<p>So &#8230; We have more computing power now and we want to use it efficiently, we want to keep these cpus busy.<br />
Of course this is not easy, in order to get a faster program, having more than one cpu does not make automatically any of your applications faster. One must choose the right technology in order to achieve the most efficiency out of these new <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Multi-core" target="_blank">multi-core</a> cpus.</p>
<p><a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Multithreading" target="_blank">Multi-threading</a> is the most common chosen technology to try to use the multiple cores available on your $600 desktop or +10,000$ on your brand new server.<br />
But multi-threading is not the <strong>only</strong> technology that does exist to maximize your computing efficiency nor it is the <strong>right</strong> technology to solve every problem: <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Multiprocessing" target="_blank">multi-processing</a> is also a good choice under certain circumstances.</p>
<p>So you want to optimize or develop a new program that would scale when in presence of multiple cores/cpus, here are the steps I follow when trying it:</p>
<p><strong>First things first:</strong><strong> check the operating system the program is supposed to run on.</strong></p>
<ul>
<li>why: not all operating systems are created equal when dealing with multiple cpus. Even if your preferred OS claims to support multiple cores it may not be able to use them efficiently i.e. where are the  <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Giant_lock" target="_blank">GL</a> contention point in your OS ?</li>
</ul>
<ul>
<li>example: if your new application is a networking app and you think that multiple cpus will make it faster you should check if your OS implements a <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/Giant_lock" target="_blank">BGL</a> around networking APIs.</li>
</ul>
<ul>
<li>conclusion: check your OS internals regarding areas where you expect multiple core to speed-up your application. usually I use SOLARIS and Linux, I tend to avoid MAC OSX and other UNIX like <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/HP-UX" target="_blank">HP-UX</a> and <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/IBM_AIX" target="_blank">IBM AIX</a>. I do not use windows boxes, hence I cannot make any comment on them.</li>
</ul>
<p>I will not speak of correct time-sharing and scheduling in presence of multiple cores since all these OS have good support for those.</p>
<p><strong>choose between multi-threading and multi-processing.</strong><br />
As I previously said, multi-threading is not always the right choice for your multi-core applications. This always a shock to people I talk with, since for them multi-threading is the only answer to multi-core programming.<br />
So here are a description of situations where multiple processes may be a better choice than multiple threads in a single process:</p>
<ul>
<li>robustness, multiple threads share the same address space, hence if one generates a fault, the whole application may crash. Multi-thread applications do not run in complete isolation, so if certain threads of your program MUST stay alive no matter what can happen to the other threads, multi-threading may be a bad choice. If restarting the program upon failure is not an issue, you can safely ignore the robustness requirement.</li>
<li>integrity, when designing multiple processes application, each process has its own address space so if one process goes crazy, it cannot corrupt the other processes data, it can only corrupt the shared data between processes. On the other hand, if a thread goes crazy it can corrupt the other threads data since there is no memory protection between threads. This is particularly true when a parent spawns a child process, the child process does whatever computation it needs, and then terminate. If any corruption occurs when doing the computation, it just goes away when the child dies: a new process is spawn to handle a new computation without being affected the previous child fault. There is no such safety net with threads. Corruption made by one thread is program wide, regardless of its lifetime.</li>
</ul>
<p>Now a description of when a multi-threading application is more desirable than a multi-process one:</p>
<ul>
<li>CPU bound applications, video/sound/images processing, numerical simulations (finite elements, molecules interactions)</li>
<li>high bandwidth message passing, this is when multiple threads exchanges messages for processing at very high rate i.e. the processing done on the various messages is very lightweight.</li>
<li>cache friendly code, this is related to CPU bound applications</li>
<li>model driven, multiple threads just make your coding easier: 1 request to be processed by 1 thread, like network connections etc. (yep this is naive e.g. see <a class="wp-caption-dd" href="http://www.kegel.com/c10k.html" target="_blank">C10K</a> problem,<a class="wp-caption-dd" href="http://pl.atyp.us/content/tech/servers.html" target="_blank"> high performance server design</a>)</li>
</ul>
<p>Still not decided between multi-threaded and multi-process application ?</p>
<p>Measure the time necessary for the computations, if this amount of time is really small i.e. lightweight computation, compare it to the time taken to increment/decrement a semaphore between 2 processes. If they are in the same order of magnitude, you probably be more satisfied with multi-threading<br />
Otherwise, multi-processing is a very viable choice. Multi-processing is a good choice when the computation takes an order of magnitude more time than the time spent exchanging data.</p>
<p><strong>reduce contention</strong><br />
See <a class="wp-caption-dd" href="http://www.ddj.com//architect/208200273" target="_blank">ddj article</a> &#8211; that&#8217;s what will kill your application (regardless of multi-threading or multi-processing).</p>
<ul>
<li>reduce code size that is protected by mutexes/semaphores i.e. a whole numerical simulation between two threads is a bad idea</li>
</ul>
<ul>
<li>reduce the necessity for locking, fastest way of sharing data between two threads ? No sharing at all !!! if you are in a master/slave processing model, try to have the master make a copy of the data to be protected by the mutex/semaphore and feed the copy to the various slaves. Copying the shared data can be way much cheaper than competing for a lock (especially when the number of threads increase).</li>
</ul>
<ul>
<li>try to use dirty-reads, do you really need to know the exact value of a shared data i.e. the value of a counter.<br />
Example: you have to remove items from a cache when the item is expired. The item expires at 11:00, the current timestamp value is protected by a mutex. Locking can be avoided, since reading 11:00 or 11:01 (it has been updated by another thread while reading it) does not really mater: as soon as the timestamp is greater than 11:00 deletion can be performed. Your counter/timestamp is quite big ? See if <a class="wp-caption-dd" href="http://portal.acm.org/citation.cfm?id=128736" target="_blank">Lamport concurrent reading and writing of clocks algorithm</a> applies to you (it&#8217;s simple and effective).</li>
<li>do not forget that memory is not cheap to access, check some <a class="wp-caption-dd" href="http://www.nwcpp.org/Downloads/2007/Machine_Architecture_-_NWCPP.pdf" target="_blank">machine architecture docs</a> to educate yourself on these low levels issues</li>
</ul>
<p><strong>If dealing with a CPU bound application, beware of trashing</strong>: that <a class="wp-caption-dd" href="http://docs.sun.com/source/819-0501/7_tuning.html" target="_blank">beast</a> will decrease your performance while maintaining your various cores busy<br />
<strong></strong></p>
<p><strong>If dealing with a CPU bound application, maximize the use of your cpu architecture</strong>. This is quite a last resort action, but it can be <strong>very</strong> effective.<br />
For example, I had to a given computation on a <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/PowerPC" target="_blank">powerpc</a> processor. The computation involved multiple floating point operations. The <a class="wp-caption-dd" href="http://en.wikipedia.org/wiki/PowerPC" target="_blank">powerpc</a> is a beautiful beast, you have multiple floating point engines when doing the calculations (in my case 4 if I remember correctly).</p>
<p>The trick was to make the compiler produce code that use all of them.</p>
<p><strong>The  following code and discussion are not about loop unrolling</strong> (yes it is closely related), here we try to avoid stalling the cpu pipeline by using the multiples floating point units.</p>
<p>original code (and simplified code):</p>
<pre>float* a = new float[1000];
float* b = new float[1000];
float* c = new float[1000];
// most cpu time was spent in there...
for ( int i = 0; i &lt; 1000; ++i )
{
    c[i] = 0;
    for ( int j = 0; j &lt; 1000; ++j )
    {
        c[i] += a[j] * b[j];
    }
}</pre>
<p>updated loop:</p>
<pre>for ( int i = 0; i &lt; 1000; ++i )
{
    float partial_sum = 0;
    for (int j = 0; j &lt; 1000; j += 4)
    {
        // load data into the various processor registers
        float a1 = a[j];
        float a2 = a[j+1];
        float a3 = a[j+2];
        float a4 = a[j+3];
        float b1 = b[j];
        float b2 = b[j+1];
        float b3 = b[j+2];
        float b4 = b[j+3];

        // compute all sums in isolation, so they can be mapped
        // independantly to the various floating point engines
        float s1 = a1 * b1; // FPU engine 1
        float s2 = a2 * b2; // FPU engine 2
        float s3 = a3 * b3; // FPU engine 3
        float s4 = a4 * b4; // FPU engine 4

        s1 += s2; // FPU engine 1
        s3 += s4; // FPU engine 2

        partial_sum += s1 + s3; // FPU engine 1
    }
    c[i] = partial_sum;
}</pre>
<p>This is longer but much more efficient and related to multi-threading: you are using the concurrency offered by your processor at the operation level: s1, s2, s3, s4 are computed in parallel, then s1 and s3 are computed in parallel again. This is very good, and most of the time, neglected source of concurrency for your programs.</p>
<p>The previous code, the updated loop, will probably be faster even on classic x86 chips with only 1 FPU, reason being that placing data in registers (explicitly) will be faster than retrieving the data from the cache.</p>
<p>Forget about the fact that this is a powerpc processor and there are multiple FPU engines etc.<br />
What we <strong>really</strong> did here, was to provide the compiler with <strong>lot</strong> of context, on how the operation should be done and handled. After that the compiler can work on the optimizations, register allocations etc. Always provide your compiler a maximum of context on the computation to be performed.</p>
<p><strong>You are not alone, seek advices and help</strong><br />
The conclusion to this post is: think twice before writing a multi-core application, check the os, your design and implementation with these previous notes before writing any line of code. Get some help from old schools SMP programmers, get them to review the design and get them to give you some tips. Multi-core programming is hard, really hard.</p>
<p>That&#8217;s all folks, for now. I&#8217;ll probably make a few other posts about multi-core programming, I have yet to decide the material to write on ;-)</p>
<p>Enjoy and share.</p>
<br />Posted in concurency, programming, software development Tagged: c, cpp, multithread <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vodoom.wordpress.com/73/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vodoom.wordpress.com/73/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vodoom.wordpress.com/73/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vodoom.wordpress.com&amp;blog=3664055&amp;post=73&amp;subd=vodoom&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vodoom.wordpress.com/2008/12/16/multi-core-programming-and-design-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/54d8f0c9b1857ed566e0eb77c3595856?s=96&#38;d=wavatar&#38;r=PG" medium="image">
			<media:title type="html">ppi</media:title>
		</media:content>
	</item>
	</channel>
</rss>
