    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Building Sculptures out of Holes</title>
        <link>https://members.accu.org/index.php/journals/1180</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">CVu Journal Vol 14, #4 - Aug 2002</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c113/">144</a>
                    (17)
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Building Sculptures out of Holes</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 03 August 2002 13:15:53 +01:00 or Sat, 03 August 2002 13:15:53 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e18" id="d0e18"></a></h2>
</div>
<div class="blockquote">
<blockquote class="blockquote">
<p>If fifty million people say a foolish thing, it's still a
foolish thing. Bertrand Russell</p>
</blockquote>
</div>
<p>I've been working on an embedded system lately. My specific
problem was to install an operating system (in my case GNU/Linux)
on a device that, though i386-compatible, doesn't have a cdrom or
floppy drive. There's no video card, no keyboard interface, just a
serial port, an Ethernet and an ISDN interface. It has a 15 MB
flash disk that can be programmed via the serial port. The system's
BIOS has a remote control feature that is executed on startup and
reads 15 MB of binary data for the disk. The only way to install
the operating system is to supply a complete image of an already
set up and configured system as one file ready to be programmed
into the flash disk by the BIOS utility. Take a file, program the
disk, toggle power and the system runs. In theory. In practice,
this file must come equipped with a properly compiled and installed
kernel, a boot loader, a partition table, and so on.</p>
<p>Under Linux, with a few tricks, you can treat a file just like a
disk (i.e. a block device). Then, to create the operating system
image, use &quot;dd if=/dev/zero of=image bs=512 count=31296&quot; (for this
special system) and you get a file called &quot;image&quot; with the desired
size consisting only of zeros. You partition it with fdisk, mount
it, copy the kernel onto it and install the boot loader (LILO).
fdisk and lilo, the LInux LOader map installer, took about 10
seconds each on my machine, dd took another 3 seconds. This was
clearly too much, so I decided to speed it up. After experimenting
a day or two without promising results, I figured that I had to
write my own partitioning tool. This could be kept very simple,
since it didn't have to do protocol with a real hard disk. It was
just a matter of writing a few bytes at a fixed position in the
file. That done, the whole image creation process took about 13
seconds, 10 seconds less than before. This seemed to be the sound
barrier because replacing lilo with an own implementation was far
to much work. And optimising away the 3 seconds of dd wouldn't pay
off, right?</p>
<p>Wrong. I was curious. I had the idea of replacing dd with a
small program that would just create the 15 MB file as a file
without real content. Even without the zeros. In Unix jargon, this
is called a file with holes. You create a new file, fseek to some
position p, write just one byte and close it again. What you get is
an empty file with p+1 bytes in size. On the disk, however, this
file would take almost no space, at least if your file system
supports that. With that change, I anticipated a total runtime of
about 10 seconds for the image creation. When I tested, it took
only about 3 seconds! Clearly, the file with holes has sped up
lilo.</p>
<p>Why do I tell you this story? Because I found it just funny how
my curiosity about these files with holes led me to this
non-obvious optimisation. This was clearly a matter of coincidence.
In the last issue of CVu, in his &quot;Professionalism in Programming&quot;
column, Pete Goodliffe wrote about curiosity being one of the key
qualities of a good programmer. Could it be that this curiosity
more often than not leads to such lucky coincidences, such
solutions that can't be planned? solutions that can't be designed?
Could it be that some of the best features in software out there
were found by accident by a curious programmer? It's clear that one
doesn't become a good programmer just by having luck. But maybe one
gets luck just by being curious.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
