<?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>delx &#187; osx</title>
	<atom:link href="http://delx.net.au/blog/tag/osx/feed/" rel="self" type="application/rss+xml" />
	<link>http://delx.net.au/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 01 Jul 2010 11:59:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fink for Mac OS X package management</title>
		<link>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/</link>
		<comments>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 00:34:31 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[fink]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=170</guid>
		<description><![CDATA[Fink is a package management system for Mac OS X. If you&#8217;re new to Fink read on for a description of how it works. The Fink project has two components. First, the port of Debian&#8217;s apt-get tools to Mac OS X combined with a binary package repository for the stable distribution. Second, the &#8216;fink&#8217; command [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.finkproject.org">Fink</a> is a package management system for Mac OS X. If you&#8217;re new to Fink read on for a description of how it works.</p>
<p><span id="more-170"></span></p>
<p>The Fink project has two components. First, the port of <a href="http://www.debian.org">Debian&#8217;s</a> apt-get tools to Mac OS X combined with a binary package repository for the stable distribution.</p>
<p>Second, the &#8216;fink&#8217; command line tool. It generates <tt>.deb</tt> packages from a source package description (located in <tt>/sw/fink/dists</tt>). Once generated you can move these packages between machines and install them with apt-get or dpkg as you would in Debian. This can save rebuilding from source.</p>
<p>Next the infamous stable vs unstable distributions. Unstable in Fink has the same meaning as it does with Debian. Don&#8217;t be too scared of using unstable. It won&#8217;t make your system crash. What it will do is have up to date packages (in most cases). It will get more frequent updates, meaning you&#8217;ll have more to recompile more often. Because of this, if you&#8217;re using the unstable distribution there tends not to be any prebuilt binaries so installation can take longer than in Debian. Also note these more recent packages may have had less testing, so sometimes they may not install.</p>
<p>One other thing you should know about is a neat package called &#8216;debfoster&#8217;. It&#8217;ll help you clean out unused packages and libraries. One of the consequences of Fink unstable building from source is that you often get lots of development packages installed that you don&#8217;t need anymore.</p>
<p>Just install debfoster and run it as root, then answer either y(es), n(o) or p(rune) to keep a package and its deps, not keep, or remove a package and all it&#8217;s deps. It&#8217;s quite clever. Give it a shot.</p>
<p>Finally, remember Fink is a volunteer project that you can contribute to. If you find a missing or out of date package, feel free to dig in to the <tt>.info</tt> file and update it. This is often as easy as just changing the version number. See the <a href="http://www.finkproject.org">Fink</a> website for a good packaging tutorial and reference.</p>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2009/04/fink-for-mac-os-x-package-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HFS+ auto defragmentation of files under Mac OS X</title>
		<link>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/</link>
		<comments>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 02:14:17 +0000</pubDate>
		<dc:creator>delx</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[defrag]]></category>
		<category><![CDATA[hfs]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://delx.net.au/blog/?p=13</guid>
		<description><![CDATA[HFS+ automatically defragments files as they are used. When a fragmented file is opened, if the system has been up for 3 minutes, the file is not busy and is under 20MiB in size then it will be relocated to be in a contiguous section of the disk So I was having a discussion with [...]]]></description>
			<content:encoded><![CDATA[<p>HFS+ automatically defragments files as they are used. When a fragmented file is opened, if the system has been up for 3 minutes, the file is not busy and is under 20MiB in size then it will be relocated to be in a contiguous section of the disk</p>
<p><span id="more-13"></span></p>
<p>So I was having a discussion with Greg yesterday about file systems and I claimed the above. I have actually made this claim, that OS X automatically defragments files, many times in the past. However this time Greg decided to call me on it. He told me: <i>Citation needed</i>.</p>
<p>I knew I&#8217;d read this somewhere, but couldn&#8217;t track my original source. So I did a little bit of research and found there wasn&#8217;t an easily accessible authoritative source anywhere.</p>
<p><a href="http://support.apple.com/kb/HT1375">Apple Technote HT1375</a> was one of the first pages I found. However it only talks about the Hot-File-Adaptive-Clustering, which is a completely different technique.</p>
<p>A little more searching and I found this Ars Technica article, a <a href="http://arstechnica.com/reviews/os/macosx-10-3.ars/5">review of Mac OS X 10.3</a>. This actually contains some solid details on the auto defragmentation feature. The reference for this information is only a <a href="http://article.gmane.org/gmane.comp.macosx.general/22906">newsgroup post</a> on comp.macosx.general, not exactly definitive.</p>
<p>So I decided to go to the source. Apple publishes the source code for large components of Mac OS X in the <a href="http://www.opensource.apple.com/darwinsource/Current/">Darwin Source Code</a> repository. In this case we needed to look at the HFS+ driver, which is part of XNU &#8211; the OS X kernel.<br />
Incidentally, thanks go to Apple for making this code available to everybody for random research like this.</p>
<p>Before long I&#8217;d narrowed it down to this file: <a href="http://www.opensource.apple.com/darwinsource/10.5.5/xnu-1228.7.58/bsd/hfs/hfs_vnops.c">xnu-1228.7.58/bsd/hfs/hfs_vnops.c</a>. The function that we&#8217;re interested in is <tt>hfs_vnop_open()</tt>, which is called whenever the system needs to open a file or directory on disk for reading or writing. The last two comments in that function explain the conditions under which defragmentation occurs. Nicely written and well commented code.</p>
<p>Since you need a free Apple developer account to view the above link, here&#8217;s the relevant section of the source code:</p>
<pre>
/*
 * Open a file/directory.
 */
static int
hfs_vnop_open(struct vnop_open_args *ap)
{
  struct vnode *vp = ap-&gt;a_vp;
  struct filefork *fp;
  struct timeval tv;
  int error;

  /*
   * Files marked append-only must be opened for appending.
   */
  if ((VTOC(vp)-&gt;c_flags &amp; APPEND) &amp;&amp; !vnode_isdir(vp) &amp;&amp;
      (ap-&gt;a_mode &amp; (FWRITE | O_APPEND)) == FWRITE)
    return (EPERM);

  if (vnode_isreg(vp) &amp;&amp; !UBCINFOEXISTS(vp))
    return (EBUSY);  /* file is in use by the kernel */

  /* Don't allow journal file to be opened externally. */
  if (VTOC(vp)-&gt;c_fileid == VTOHFS(vp)-&gt;hfs_jnlfileid)
    return (EPERM);
  /*
   * On the first (non-busy) open of a fragmented
   * file attempt to de-frag it (if its less than 20MB).
   */
  if ((VTOHFS(vp)-&gt;hfs_flags &amp; HFS_READ_ONLY) ||
      (VTOHFS(vp)-&gt;jnl == NULL) ||
#if NAMEDSTREAMS
      !vnode_isreg(vp) || vnode_isinuse(vp, 0) ||
      vnode_isnamedstream(vp)) {
#else
      !vnode_isreg(vp) || vnode_isinuse(vp, 0)) {
#endif
    return (0);
  }

  if ((error = hfs_lock(VTOC(vp), HFS_EXCLUSIVE_LOCK)))
    return (error);
  fp = VTOF(vp);
  if (fp-&gt;ff_blocks &amp;&amp;
      fp-&gt;ff_extents[7].blockCount != 0 &amp;&amp;
      fp-&gt;ff_size &lt;= (20 * 1024 * 1024)) {
    struct timeval now;
    struct cnode *cp = VTOC(vp);
    /*
     * Wait until system bootup is done (3 min).
     * And don't relocate a file that's been modified
     * within the past minute -- this can lead to
     * system thrashing.
     */
    microuptime(&amp;tv);
    microtime(&amp;now);
    if (tv.tv_sec &gt; (60 * 3) &amp;&amp;
       ((now.tv_sec - cp-&gt;c_mtime) &gt; 60)) {
      (void) hfs_relocate(vp, VTOVCB(vp)-&gt;nextAllocation + 4096,
                          vfs_context_ucred(ap-&gt;a_context),
                          vfs_context_proc(ap-&gt;a_context));
    }
  }
  hfs_unlock(VTOC(vp));

  return (0);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://delx.net.au/blog/2008/11/hfs-auto-defragmentation-of-files-under-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
