<?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/"
	>

<channel>
	<title>n8blog &#187; Tips</title>
	<atom:link href="http://www.n8gray.org/blog/category/apple/os_x/tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.n8gray.org</link>
	<description>distraction in action</description>
	<lastBuildDate>Thu, 01 Jul 2010 18:21:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Printing from OS X 10.5 to Ubuntu</title>
		<link>http://www.n8gray.org/blog/2008/06/12/printing-from-os-x-105-to-ubuntu/</link>
		<comments>http://www.n8gray.org/blog/2008/06/12/printing-from-os-x-105-to-ubuntu/#comments</comments>
		<pubDate>Fri, 13 Jun 2008 02:20:15 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/?p=175</guid>
		<description><![CDATA[This took me waaaay too long to figure out.  A while back I set up printer sharing (with browsing) on my Ubuntu-based server.  My Mac (running Tiger at the time) found the server just fine and it all just worked &#8212; I couldn&#8217;t believe how simple it was!  But then I upgraded [...]]]></description>
			<content:encoded><![CDATA[<p>This took me waaaay too long to figure out.  A while back I set up printer sharing (with browsing) on my Ubuntu-based server.  My Mac (running Tiger at the time) found the server just fine and it all just worked &#8212; I couldn&#8217;t believe how simple it was!  But then I upgraded to Leopard, and among the (numerous) casualties was the shared printer.  No matter what I tried, what protocol I used, what driver I used, the shared printer just wouldn&#8217;t work.  After hours of banging my head against the keyboard I let it go.  About 9 months have passed, and today I decided to take one more swing at.  Can you believe it?  I found the problem!  There were two problems really.</p>

<p>First, to access a shared printer on <strong>another</strong> machine, you have to turn on print sharing on <strong>your</strong> machine.  This defies all logic, but there you go.</p>

<p>Second, for some utterly inscrutable reason <a href="http://docs.info.apple.com/article.html?artnum=306984">Apple decided to *dis*able the <span class="caps">CUPS </span>browsing protocol, leaving only Bonjour browsing working</a>.  ????  Stupid.  Stupid.  Stupid.  It&#8217;s as if they said &#8220;let&#8217;s make sure Mac users will have lots of trouble printing to Linux servers, that&#8217;ll improve our customer satisfaction!&#8221;  To fix this lameness, do the following:</p>

<code> cupsctl BrowseProtocols='&quot;cups dnssd&quot;'</code>

<p>Combining these two tips, the shared printer <strong>finally</strong> appeared in the &#8220;Default&#8221; pane of the new printer dialog and printing to it just worked.  Hopefully Apple makes this more sensible in Snow Leopard&#8230;</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2008%2F06%2F12%2Fprinting-from-os-x-105-to-ubuntu%2F&amp;linkname=Printing%20from%20OS%20X%2010.5%20to%20Ubuntu"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2008/06/12/printing-from-os-x-105-to-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Unix Commands Unique to Darwin</title>
		<link>http://www.n8gray.org/blog/2005/10/14/unix-commands-unique-to-darwin/</link>
		<comments>http://www.n8gray.org/blog/2005/10/14/unix-commands-unique-to-darwin/#comments</comments>
		<pubDate>Fri, 14 Oct 2005 12:52:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=53</guid>
		<description><![CDATA[
Here&apos;s a list of Unix commands that only appear in Darwin.  wait4path looks handy, and so do authopen and textutil.  PPCExplain would be cool if Apple weren&apos;t dropping the PPC platform.  I&apos;m always meaning to do something slick with pbcopy and pbpaste, but I&apos;m never sure exactly what.]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://www.matisse.net/OSX/darwin_commands.html">Here&apos;s</a> a list of Unix commands that only appear in <a href="http://developer.apple.com/darwin/">Darwin</a>.  wait4path looks handy, and so do authopen and textutil.  <span class="caps">PPCE</span>xplain would be cool if Apple weren&apos;t dropping the <span class="caps">PPC </span>platform.  I&apos;m always meaning to do something slick with pbcopy and pbpaste, but I&apos;m never sure exactly what.<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2005%2F10%2F14%2Funix-commands-unique-to-darwin%2F&amp;linkname=Unix%20Commands%20Unique%20to%20Darwin"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2005/10/14/unix-commands-unique-to-darwin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keybindings 4-evah!</title>
		<link>http://www.n8gray.org/blog/2005/04/14/keybindings-4-evah/</link>
		<comments>http://www.n8gray.org/blog/2005/04/14/keybindings-4-evah/#comments</comments>
		<pubDate>Thu, 14 Apr 2005 16:39:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=67</guid>
		<description><![CDATA[
OMG!  OMG!  From the Advanced Technology section of Apple&apos;s Tiger Preview:

Remappable Modifier Keys

Remap modifiers such as control and caps lock to be super elite.


Who knew that remapping modifier keys required Advanced Technology?

Now I&apos;ve got to upgrade!  I mean, uControl is nice and all, and it&apos;s made life under OS X bearable, but [...]]]></description>
			<content:encoded><![CDATA[<p>
<span class="caps">OMG</span>!  <span class="caps">OMG</span>!  From the <a href="http://www.apple.com/macosx/overview/advancedtechnology.html">Advanced Technology section</a> of Apple&apos;s <a href="http://www.apple.com/macosx/">Tiger Preview</a>:<br />
<blockquote>
<b>Remappable Modifier Keys</b><br />
<br /><br />
Remap modifiers such as control and caps lock to be super elite.<br />
</blockquote>
<p>
Who knew that remapping modifier keys required Advanced Technology?<br />
<p>
Now I&apos;ve <em>got</em> to upgrade!  I mean, <a href="gnufoo.org/ucontrol/ucontrol.html">uControl</a> is nice and all, and it&apos;s made life under OS X bearable, but it&apos;s a bit on the flaky side.  The caps-lock <span class="caps">LED </span>continues to turn on and off even when caps-lock is changed to another key.  Also, caps-lock-clicking on links in Safari does different things depending on the state of the button, despite the fact that it&apos;s now supposed to be stateless.<br />
<p>
Please, oh please, Apple, don&apos;t screw this up!  Give us a way to remap modifier keys <em>arbitrarily</em>, not just a &#8220;swap caps-lock and control&#8221; checkbox.  In OS X it&apos;s handier to have caps-lock be command, since that&apos;s the main modifier key for most keyboard shortcuts.<br />
<p>
On a more serious note, it&apos;s nice to see that the basic unix command line utilities like <code>mv</code>, <code>cp</code>, and <code>tar</code> will <em>actually finally work reliably</em> in Tiger.  Up until now, moving a file using <code>mv</code> would cause its resource fork to be lost, potentially ruining it.  Pretty shameful for an OS claiming to be &#8220;Based on <span class="caps">UNIX</span>&#8220;.<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2005%2F04%2F14%2Fkeybindings-4-evah%2F&amp;linkname=Keybindings%204-evah%21"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2005/04/14/keybindings-4-evah/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet Again, Keybindings</title>
		<link>http://www.n8gray.org/blog/2004/08/27/yet-again-keybindings/</link>
		<comments>http://www.n8gray.org/blog/2004/08/27/yet-again-keybindings/#comments</comments>
		<pubDate>Fri, 27 Aug 2004 14:00:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=72</guid>
		<description><![CDATA[I thought I would finish out the &#8220;keybindings trilogy&#8221; with these additional bindings that I use:



    /* Page up/down should move the cursor, not just scroll */
    &#34;\UF72C&#34;    = &#34;pageUp:&#34;;
    &#34;\UF72D&#34;    = &#34;pageDown:&#34;;

    /* Cmd+Left/Right for next/prev [...]]]></description>
			<content:encoded><![CDATA[<p>I thought I would finish out the &#8220;<a href="/blog/2004/05/07#keybindings">keybindings</a> <a href="/blog/2004/05/18#keybindings2">trilogy</a>&#8221; with these additional bindings that I use:


<pre>
    /* Page up/down should move the cursor, not just scroll */
    &quot;\UF72C&quot;    = &quot;pageUp:&quot;;
    &quot;\UF72D&quot;    = &quot;pageDown:&quot;;

    /* Cmd+Left/Right for next/prev word */
    &quot;@\UF702&quot;   = &quot;moveWordLeft:&quot;;
    &quot;@\UF703&quot;   = &quot;moveWordRight:&quot;;

    &quot;~-&quot;        = &quot;selectWord:&quot;;    /* Alt-Minus */
</pre>


<p>Enjoy!</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F08%2F27%2Fyet-again-keybindings%2F&amp;linkname=Yet%20Again%2C%20Keybindings"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/08/27/yet-again-keybindings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Hex Plugin for the OS X Color Picker</title>
		<link>http://www.n8gray.org/blog/2004/08/26/a-hex-plugin-for-the-os-x-color-picker/</link>
		<comments>http://www.n8gray.org/blog/2004/08/26/a-hex-plugin-for-the-os-x-color-picker/#comments</comments>
		<pubDate>Fri, 27 Aug 2004 03:13:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=73</guid>
		<description><![CDATA[Anybody who&apos;s messed with the OS X color chooser has noticed that it&apos;s quite
a versatile tool with lots of nice features.  However, there&apos;s one glaring
deficiency that rears its head if you try to use it in conjunction with web
design.  Say you&apos;ve picked a nice palette for your website using the color
picker and want [...]]]></description>
			<content:encoded><![CDATA[<p>Anybody who&apos;s messed with the OS X color chooser has noticed that it&apos;s quite
a versatile tool with lots of nice features.  However, there&apos;s one glaring<br />
deficiency that rears its head if you try to use it in conjunction with web<br />
design.  Say you&apos;ve picked a nice palette for your website using the color<br />
picker and want to code it up.  All you need is the hex values of your colors. <br />
Uh oh.  The color picker has no way to show you the hex values of your colors! <br />
Astonishing, but true.</p>
<p>
Luckily, Lucky Software has written a plugin for the color picker (who knew that<br />
there were such things??) that provides this functionality.  It can display the<br />
numerical representation of your colors in a variety of formats, including<br />
#rrggbb, #rgb, rgb(%r, %g, %b), and rgb(rrr,ggg,bbb).  It will also tell you if<br />
a color is &#8220;web safe.&#8221;  I think the only thing conceivably missing in this <br />
little plugin is the ability to display values in <span class="caps">HSV </span>and <span class="caps">CMYK </span>color spaces, <br />
but that&apos;s understandable since it was designed for the web, where <span class="caps">RGB </span>is king.<br />
</p>
<p>
You can get HexColorPicker at <a href="http://www.luckysoftware.dk/hexcolorpicker.php">http://www.luckysoftware.dk/hexcolorpicker.php</a><br />
<p>
Another interesting color picker plugin can be found <a href="http://www.oldjewelsoftware.com/ppicker/">here</a>.<br />
</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F08%2F26%2Fa-hex-plugin-for-the-os-x-color-picker%2F&amp;linkname=A%20Hex%20Plugin%20for%20the%20OS%20X%20Color%20Picker"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/08/26/a-hex-plugin-for-the-os-x-color-picker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SystemVersion.plist</title>
		<link>http://www.n8gray.org/blog/2004/05/21/systemversionplist/</link>
		<comments>http://www.n8gray.org/blog/2004/05/21/systemversionplist/#comments</comments>
		<pubDate>Fri, 21 May 2004 15:00:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=78</guid>
		<description><![CDATA[This is an interesting little file that can be found in /System/Library/CoreServices:




&#38;lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#38;gt;
&#38;lt;!DOCTYPE plist PUBLIC &#34;-//Apple Computer//DTD PLIST 1.0//EN&#34; 
 &#34;http://www.apple.com/DTDs/PropertyList-1.0.dtd&#34;&#38;gt;
&#38;lt;plist version=&#34;1.0&#34;&#38;gt;
&#38;lt;dict&#38;gt;
        &#38;lt;key&#38;gt;ProductBuildVersion&#38;lt;/key&#38;gt;
        &#38;lt;string&#38;gt;7F44&#38;lt;/string&#38;gt;
        &#38;lt;key&#38;gt;ProductCopyright&#38;lt;/key&#38;gt;
        &#38;lt;string&#38;gt;Apple [...]]]></description>
			<content:encoded><![CDATA[<p>This is an interesting little file that can be found in <code>/System/Library/CoreServices</code>:</p>



<pre>
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; 
 &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&amp;gt;
&amp;lt;plist version=&quot;1.0&quot;&amp;gt;
&amp;lt;dict&amp;gt;
        &amp;lt;key&amp;gt;ProductBuildVersion&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;7F44&amp;lt;/string&amp;gt;
        &amp;lt;key&amp;gt;ProductCopyright&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;Apple Computer, Inc. 1983-2004&amp;lt;/string&amp;gt;
        &amp;lt;key&amp;gt;ProductName&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;Mac OS X&amp;lt;/string&amp;gt;
        &amp;lt;key&amp;gt;ProductUserVisibleVersion&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;10.3.3&amp;lt;/string&amp;gt;
        &amp;lt;key&amp;gt;ProductVersion&amp;lt;/key&amp;gt;
        &amp;lt;string&amp;gt;10.3.3&amp;lt;/string&amp;gt;
&amp;lt;/dict&amp;gt;
&amp;lt;/plist&amp;gt;
</pre>



<p>
It might be fun to try tweaking this the next time Apple ties an app to the system version like they did with <span class="caps">X11.</span><br />
</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F05%2F21%2Fsystemversionplist%2F&amp;linkname=SystemVersion.plist"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/05/21/systemversionplist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More KeyBindings Knowledge</title>
		<link>http://www.n8gray.org/blog/2004/05/18/more-keybindings-knowledge/</link>
		<comments>http://www.n8gray.org/blog/2004/05/18/more-keybindings-knowledge/#comments</comments>
		<pubDate>Tue, 18 May 2004 15:00:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=79</guid>
		<description><![CDATA[My last entry discussed the
~/Library/KeyBindings/DefaultKeyBinding.dict file, but there was
one bit of knowledge left out.  Where did those key codes (e.g. Home = \UF729)
come from?  It took me a while, but now I understand.  They are described in the
header file for the NSEvent
class.  It should be located here:
/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h


Also, see this entry at
CocoaDev [...]]]></description>
			<content:encoded><![CDATA[<p><a href="/blog/2004/05/07#keybindings">My last entry</a> discussed the
<code>~/Library/KeyBindings/DefaultKeyBinding.dict</code> file, but there was<br />
one bit of knowledge left out.  Where did those key codes (e.g. Home = \UF729)<br />
come from?  It took me a while, but now I understand.  They are described in the<br />
header file for the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSEvent.html#//apple_ref/doc/c_ref/NSEvent"><span class="caps">NSE</span>vent</a><br />
class.  It should be located here:<br />
<br /><code>/System/Library/Frameworks/AppKit.framework/Headers/NSEvent.h</code><br />
</p>
<p>
Also, see <a href="http://www.cocoadev.com/index.pl?KeyBindings">this entry</a> at<br />
<a href="http://www.cocoadev.com/">CocoaDev</a> for more detailed information<br />
about this file.<br />
</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F05%2F18%2Fmore-keybindings-knowledge%2F&amp;linkname=More%20KeyBindings%20Knowledge"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/05/18/more-keybindings-knowledge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing the Home/End keys on OS X</title>
		<link>http://www.n8gray.org/blog/2004/05/07/fixing-the-homeend-keys-on-os-x/</link>
		<comments>http://www.n8gray.org/blog/2004/05/07/fixing-the-homeend-keys-on-os-x/#comments</comments>
		<pubDate>Fri, 07 May 2004 15:00:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=80</guid>
		<description><![CDATA[For some reason the Mac gods decided that Home and End scroll your window to
the beginning and end of file respectively.  This is just wrong.  They should
move the cursor to the beginning or end of the line it&apos;s on, just like they do
in every other modern UI.  Thankfully, there&apos;s a way to [...]]]></description>
			<content:encoded><![CDATA[<p>For some reason the Mac gods decided that Home and End scroll your window to
the beginning and end of file respectively.  This is just wrong.  They should
move the cursor to the beginning or end of the line it&apos;s on, just like they do
in every other modern UI.  Thankfully, there&apos;s a way to fix this for all Cocoa
apps, which for me is everything I use!</p> 

<p>
First you need to make a subdirectory called <code>KeyBindings</code> in your 
<code>~/Library</code> directory. Next, use your favorite text editor to create
a file in that directory named <code>DefaultKeyBinding.dict</code> containing
this text:</p>

<pre>
{
    "\UF729"  = "moveToBeginningOfLine:";                   /* Home */
    "\UF72B"  = "moveToEndOfLine:";                         /* End */
    "$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift-Home */
    "$\UF72B" = "moveToEndOfLineAndModifySelection:";       /* Shift-End */
}
</pre>
<p>
Restart any Cocoa apps (Safari, Mail, or TextEdit) to see the new keybindings
take effect!    
</p>

<p>
For more info on this method of binding keys see <a href="http://www.macosxhints.com/article.php?story=20010729214616497">this OS X
hint</a> and <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/BasicEventHandling/Tasks/TextDefaultsAndBindings.html">this
Apple document</a>.  The commands like <code>moveToEndOfLine:</code> are
actually &#8220;Action methods&#8221; of the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSResponder.html#//apple_ref/occ/cl/NSResponder">NSResponder</a>
Cocoa class. 
</p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F05%2F07%2Ffixing-the-homeend-keys-on-os-x%2F&amp;linkname=Fixing%20the%20Home%2FEnd%20keys%20on%20OS%20X"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/05/07/fixing-the-homeend-keys-on-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A (low performance) x86 Linux emulation and cross-development environment on OS X.</title>
		<link>http://www.n8gray.org/blog/2004/04/04/a-low-performance-x86-linux-emulation-and-cross-development-environment-on-os-x/</link>
		<comments>http://www.n8gray.org/blog/2004/04/04/a-low-performance-x86-linux-emulation-and-cross-development-environment-on-os-x/#comments</comments>
		<pubDate>Sun, 04 Apr 2004 11:03:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://sandbox.n8gray.org/blog/2004/04/04/a-low-performance-x86-linux-emulation-and-cross-development-environment-on-os-x/</guid>
		<description><![CDATA[
Lately I&apos;ve been trying to get an x86 emulation environment working on my
powerbook so I can test out the backend of our compiler.  Eventually I hope to
write a PPC backend, but in the near future x86 is the only platform it&apos;s going
to run on.  

  The first step was to build a [...]]]></description>
			<content:encoded><![CDATA[<p>
Lately I&apos;ve been trying to get an x86 emulation environment working on my<br />
powerbook so I can test out the backend of our compiler.  Eventually I hope to<br />
write a <span class="caps">PPC </span>backend, but in the near future x86 is the only platform it&apos;s going<br />
to run on.  

<p>  The first step was to build a cross-compiling version of gnu bintools for
x86.  We&apos;re generating assembly code and using gnu as to assemble it, so I<br />
would be needing a version that could generate x86-elf executables.  Happily,<br />
this was pretty straightforward:

<p>

<pre>
  $ ./configure --target=i586-unknown-linux-gnu --prefix=/usr/local/xcomp -v
  $ make all
  $ sudo make install
</pre>



<p>
I could now build little-endian x86 binaries from asm programs like the one in<br />
the <a href="http://www.tldp.org/HOWTO/Assembly-HOWTO/">Linux Assembly<br />
<span class="caps">HOWTO</span></a>.

<p>
The next step was to get an x86 emulator.  <a href="http://bochs.sourceforge.net/">Bochs</a> is the economical, open-source<br />
choice here.  There are other commercial emulators like Virtual PC that are much<br />
faster, but I just need to be able to try out tiny compiler test programs &#8211;<br />
performance is not important, and money is.  <img src='http://www.n8gray.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> 

<p>
Setting up Bochs wasn&apos;t too tough, but their bochs.scpt had a bug in it that<br />
kept it from working.  I ended up just running<br />
<code>bochs.app/Contents/MacOS/bochs</code> manually to launch the emulator.

<p>
So now I could build Linux x86 binaries and I could run Linux x86 binaries.  The<br />
only issue remaining was getting the binaries into the emulator.  What I mean is<br />
that the emulator uses a Linux ext2 filesystem inside a disk image as its<br />
virtual hard drive.  If I want to run something on the emulator I have to get it<br />
onto that hard drive (or some other drive that the emulator can access). <br />
Unfortunately, OS X doesn&apos;t have built-in support for ext2 filesystems. <br />
Fortunately, <a href="http://sourceforge.net/projects/ext2fsx/">somebody<br />
else</a> provides it.

<p>
So I downloaded ExtFSManager, installed it and rebooted.  Unfortunately, I<br />
still couldn&apos;t mount the ext2 disk images I wanted to use.  When I tried<br />
<code>open hd10meg.img</code> I would get an error complaining that the image<br />
had no mountable filesystems.  Under linux I would have tried mounting the image<br />
to a loopback device and then investigating further.  After some research I<br />
discovered that the way to do this under OS X is: <code>hdid -nomount
hd10meg.img</code>  This mounts the image as a device (e.g. <code>/dev/disk1</code>) without <br />
attempting to mount any of the filesystems on the image.  

<p>
So now I had <code>hd10meg.img</code> mounted on <code>/dev/disk1</code>.  It turns out that I just needed<br />
to fsck a partition on the filesystem to get it to mount correctly with open:<br />
<p>


<pre>
  $ sudo fsck_ext2 /dev/disk1s1    # The second partition of disk 1
  . . .
  $ hdiutil eject /dev/disk1
  $ open hd10meg.img    # everything works fine now...
</pre>



<p>
Voilla!  Now I can mount the disk image and copy files to and from it.  Next I&apos;m<br />
hoping to figure out a way to be able to copy files in and out of a running<br />
emulator.  It seems that just copying files into the mounted image while the<br />
emulator is running doesn&apos;t work.  I&apos;ll have to set up networking or use virtual<br />
floppies or something.  But that&apos;s work for another day.  <img src='http://www.n8gray.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> <a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F04%2F04%2Fa-low-performance-x86-linux-emulation-and-cross-development-environment-on-os-x%2F&amp;linkname=A%20%28low%20performance%29%20x86%20Linux%20emulation%20and%20cross-development%20environment%20on%20OS%20X."><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/04/04/a-low-performance-x86-linux-emulation-and-cross-development-environment-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
