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

<channel>
	<title>tomkarpik.com</title>
	<atom:link href="http://tomkarpik.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tomkarpik.com</link>
	<description></description>
	<pubDate>Wed, 26 Dec 2007 02:16:19 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Happy Holidays</title>
		<link>http://tomkarpik.com/articles/happy-holidays/</link>
		<comments>http://tomkarpik.com/articles/happy-holidays/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 02:15:23 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://tomkarpik.com/articles/happy-holidays/</guid>
		<description><![CDATA[Merry Christmas, Happy Hanukkah, etc. etc.

I&#8217;ll post some cute pictures and other stuff later. :-P
]]></description>
			<content:encoded><![CDATA[<p>Merry Christmas, Happy Hanukkah, etc. etc.</p>

<p>I&#8217;ll post some cute pictures and other stuff later. :-P</p>
]]></content:encoded>
			<wfw:commentRss>http://tomkarpik.com/articles/happy-holidays/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fuck the RCMP</title>
		<link>http://tomkarpik.com/articles/fuck-the-rcmp/</link>
		<comments>http://tomkarpik.com/articles/fuck-the-rcmp/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 03:13:09 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://tomkarpik.com/articles/fuck-the-rcmp/</guid>
		<description><![CDATA[Now that this is public, do you think we&#8217;ll respect you after this, and everything that happens afterwards? You best tread carefully from now on.

You four power-tripping, murdering pigs better be held accountable for the death of a poor guy who was just scared out of his mind. It doesn&#8217;t take an above-average IQ to [...]]]></description>
			<content:encoded><![CDATA[<p>Now that <a href="http://www.news1130.com/news/topstory/article.jsp?content=20071114_192318_5368">this</a> is public, do you think we&#8217;ll respect you after this, and everything that happens afterwards? You best tread carefully from now on.</p>

<p>You four power-tripping, murdering pigs better be held accountable for the death of a poor guy who was just scared out of his mind. It doesn&#8217;t take an above-average IQ to figure out that a foreigner left alone in an area of the airport, not knowing the language, or even knowing where he is, is going to get agitated, and then quite frightened. And way to go, airport staff, for helping him out.</p>

<p>Many of us will see these videos over and over again in the next few days. And since a video is not tainted with bias or personal interpretation, it will be made clear to everyone that the intention to taser said victim was there from the start &#8212; unprovoked.</p>

<p>Fuck you four, and everyone who stands behind you in your defense.</p>
]]></content:encoded>
			<wfw:commentRss>http://tomkarpik.com/articles/fuck-the-rcmp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Massive Data Loss Bug in Leopard</title>
		<link>http://tomkarpik.com/articles/massive-data-loss-bug-in-leopard/</link>
		<comments>http://tomkarpik.com/articles/massive-data-loss-bug-in-leopard/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 18:24:35 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
		
		<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://tomkarpik.com/articles/massive-data-loss-bug-in-leopard/</guid>
		<description><![CDATA[Update: The bug occurs regardless of the type of destination being moved to (whether it&#8217;s local USB, local Firewire, SMB, etc.). Also, I have been informed that this bug goes back all the way to Panther.

Update 2: Here&#8217;s a video of the same thing happening to a USB drive: leopardmovebug.avi

Update 3: Robert Rodgers adds: &#8220;I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> <em>The bug occurs regardless of the type of destination being moved to (whether it&#8217;s local USB, local Firewire, SMB, etc.). Also, I have been informed that this bug goes back all the way to Panther.</em></p>

<p><strong>Update 2:</strong> <em>Here&#8217;s a video of the same thing happening to a USB drive: <a href="http://tomkarpik.com/pub/leopardmovebug.avi">leopardmovebug.avi</a></em></p>

<p><strong>Update 3:</strong> <em>Robert Rodgers adds: &#8220;I accidently chmod&#8217;d a directory while a massive (40+GB) file move was being copied into it to be -w by me, files went &#8216;poof&#8217;.&#8221;</em></p>

<p>Leopard&#8217;s Finder has a glaring bug in its directory-moving code, leading to horrendous data loss if a destination volume disappears while a move operation is in action. I first came across it when Samba crashed while I was moving a directory from my desktop over to a Samba mount on my FreeBSD server.</p>

<p>I&#8217;ve now run tests on a Windows XP SP2 SMB mount, as well as a local HFS+ formatted USB drive, and the bug surfaces every time the destination disappears while the Finder is moving something to the destination.</p>

<p><span id="more-29"></span></p>

<h3>Details</h3>

<p>Before I go into more detail, let&#8217;s clear up what it means to &#8220;copy&#8221; or &#8220;move&#8221; a file:</p>

<p><strong>Copying from/to the same volume:</strong> A new file reference is created on the file system, and then data is read from the source and written to the destination.</p>

<p><strong>Moving from/to the same volume:</strong> The file reference is modified to reflect the new path. No data is ever read/written.</p>

<p><strong>Copying from/to different volumes:</strong> A new file reference is created on the file system of the other volume, and then data is read from the source on the original volume, and written to the destination.</p>

<p><strong>Moving from/to different volumes:</strong> A new file reference is created on the file system of the other volume, and then data is read from the source on the original volume, and written to the destination. If the previous operation is successful, the original file on the original volume is deleted.</p>

<p>As you can see, moving a file from one location to another on the same volume is a piece of cake. Moving a file between two volumes really incorporates two file system operations: a copy, and then a delete &#8230; <em>but only if the copy was successful</em> (at least on a sane system!).</p>

<p>In terms of pseudo code, moving from/to different volumes might look something like this:</p>

<pre><code>move(source, destination) {
    returnVal = copy(source, destination);

    if(returnVal == TRUE) {      // copy success
        delete(source);
    } else {                     // copy fail
        message("Move failed");
    }
}
</code></pre>

<p>This is where the problem with the Mac OS X 10.5.0 Finder lies.</p>

<h3>Demonstration</h3>

<p>The following is a simple demonstration that anyone with a SMB server (be it Windows itself, Samba on FreeBSD/Linux, etc.) can duplicate. The specifications for the demonstration were as follows:</p>

<h4>Client</h4>

<p>MacBook Pro (2.0 GHz Core Duo, 2 GB of RAM)<br />
Mac OS X Leopard (10.5.0)</p>

<h4>Server</h4>

<p>Same MacBook Pro running VMware<br />
Windows XP SP2</p>

<p>For my purposes, I simply booted up Windows XP in VMware and connected to it as if it were a whole separate computer (OS X doesn&#8217;t know the difference).</p>

<p>Let&#8217;s go through the regular rigmarole of finding a Windows PC&#8217;s IP and connecting to it through SMB (<em>&#8220;Windows File Sharing&#8221;</em>).</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug1.png" alt="leopardbug1.png" style="border: 0;" />
<img src="http://tomkarpik.com/pub/leopardbug/leopardbug2.png" alt="leopardbug2.png" style="border: 0;" />
<img src="http://tomkarpik.com/pub/leopardbug/leopardbug3.png" alt="leopardbug3.png" style="border: 0;" />
<img src="http://tomkarpik.com/pub/leopardbug/leopardbug4.png" alt="leopardbug4.png" style="border: 0;" /></p>

<p>Great. We now have <code>C:\</code> mounted on our Mac running Leopard. Let&#8217;s prepare for the simulated SMB mount failure by opening <code>Computer Management\System Tools\Shared Folders\Sessions</code> in Windows.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug5.png" alt="leopardbug5.png" /></p>

<p>Our Mac&#8217;s connection to the share should be obvious.</p>

<p>Let&#8217;s now open a Terminal on our Mac, and create a directory with some garbage data in it. Generate enough data so that a move operation will take at least 10 seconds. In my case, my test file is 384 MB.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug6.png" alt="leopardbug6.png" style="border: 0;" /></p>

<p>(The command I used to generate the test directory with a garbage file is as follows: <code>mkdir test &amp;&amp; dd if=/dev/random of=test/testfile bs=4096 count=98304</code>)</p>

<p>You&#8217;ll now see a <code>"test"</code> directory on your Desktop.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug7.png" alt="leopardbug7.png" /></p>

<p>Here&#8217;s the key step. Move the <code>"test"</code> directory from your Desktop to the <code>C$</code> mount by holding Command (Apple) and dragging. Dragging without holding Command will initiate a copy operation (that&#8217;s what the plus means), so be sure to hold Command until you release the drag.</p>

<p>You&#8217;ll know Finder expects to perform a move when there is no plus beside the directory you&#8217;re dragging.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug8.png" alt="leopardbug8.png" /></p>

<p>Okay, our move operation is doing its thing. (Notice how the title of the window still says &#8220;Copy&#8221;? Remember what I said about moving files across volumes?)</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug9.png" alt="leopardbug9.png" style="border: 0;" /></p>

<p>Quickly go back to the Windows session, right-click on the active share session, and close it.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug10.png" alt="leopardbug10.png" /></p>

<p>Finder will error out with one of its typically useful error messages and codes. This much is to be expected. The <code>"test"</code> directory can still be seen on our Desktop.</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug11.png" alt="leopardbug11.png" /></p>

<p>Aaaand &#8230; <em>poof!</em></p>

<p>The directory on our Desktop is now gone. The directory shown in the <code>C$</code> mount will only contain files that were copied entirely before the connection was disrupted, but nothing more (in the demonstration case, there&#8217;s only one file in <code>"test"</code>, so nothing was copied successfully).</p>

<p><img src="http://tomkarpik.com/pub/leopardbug/leopardbug12.png" alt="leopardbug12.png" />
<img src="http://tomkarpik.com/pub/leopardbug/leopardbug13.png" alt="leopardbug13.png" style="border: 0;" /></p>

<p>Where&#8217;s the rest of our data?</p>

<p>Apple, please <em>FTFF</em> already. This is unacceptable.</p>

<script>digg_url = 'http://digg.com/apple/Massive_Data_Loss_Bug_in_Leopard';</script>

<script src="http://digg.com/api/diggthis.js"></script>
]]></content:encoded>
			<wfw:commentRss>http://tomkarpik.com/articles/massive-data-loss-bug-in-leopard/feed/</wfw:commentRss>
<enclosure url="http://tomkarpik.com/pub/leopard_move_bug.avi" length="11429140" type="video/x-msvideo" />
<enclosure url="http://tomkarpik.com/pub/leopardmovebug.avi" length="11429140" type="video/x-msvideo" />
		</item>
	</channel>
</rss>
