<?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>blueslugs.com &#187; Software</title> <atom:link href="http://blueslugs.com/wordpress/category/software/feed/" rel="self" type="application/rss+xml" /><link>http://blueslugs.com/wordpress</link> <description>Observations from a West Coast family</description> <lastBuildDate>Fri, 30 Jul 2010 00:07:54 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <item><title>adirent.[ch]: Adding d_type to struct dirent on OpenSolaris</title><link>http://blueslugs.com/wordpress/2010/06/13/adirent-ch-adding-d_type-to-struct-dirent-on-opensolaris/</link> <comments>http://blueslugs.com/wordpress/2010/06/13/adirent-ch-adding-d_type-to-struct-dirent-on-opensolaris/#comments</comments> <pubDate>Mon, 14 Jun 2010 02:47:47 +0000</pubDate> <dc:creator>Stephen</dc:creator> <category><![CDATA[Software]]></category> <category><![CDATA[opensolaris]]></category><guid
isPermaLink="false">http://blueslugs.com/wordpress/?p=31588</guid> <description><![CDATA[An occasional porting problem you may encounter when compiling programs for OpenSolaris is the absence of d_type in the directory entry structure returned by readdir(3C). I hit this issue when experimenting with mu as a search solution for my accumulated email. A trivial example of the failure you might see would be caused by the [...]]]></description> <content:encoded><![CDATA[<p>An occasional porting problem you may encounter when compiling programs for OpenSolaris is the absence of <code>d_type</code> in the directory entry structure returned by <code>readdir</code>(3C).  I  hit this issue when experimenting with <a
href="http://www.djcbsoftware.nl/code/mu/">mu</a> as a search solution for my accumulated email.</p><p>A trivial example of the failure you might see would be caused by the following program:</p><pre><code>#include &lt;sys/types.h&gt;
#include &lt;dirent.h&gt;
#include &lt;err.h&gt;
#include &lt;stdio.h&gt;

int
main(int argc, char *argv[])
{
        DIR *d;
        struct dirent *e;

        if ((d = opendir("/")) == NULL)
                err(1, "opendir failed");

        for (e = readdir(d); e != NULL; e = readdir(d)) {
                    if (e-&gt;d_type != DT_UNKNOWN)
                        (void) printf("recognized filetype for '%s'\n",
                            e-&gt;d_name);
        }

        (void) closedir(d);

        return (0);
 }
</code></pre><p>When we attempt to compile this program with <code>gcc</code>, we get something like</p><pre><code>$ gcc a.c
a.c: In function `main':
a.c:16: error: structure has no member named `d_type'
a.c:16: error: `DT_UNKNOWN' undeclared (first use in this function)
a.c:16: error: (Each undeclared identifier is reported only once
a.c:16: error: for each function it appears in.)
</code></pre><p>Studio <code>cc</code> will give similar output:</p><pre><code>$ /opt/SunStudioExpress/bin/cc a.c
"a.c", line 16: undefined struct/union member: d_type
"a.c", line 16: undefined symbol: DT_UNKNOWN
cc: acomp failed for a.c
</code></pre><p>The addition of <code>d_type</code> to <code>struct dirent</code> came first for the BSD Unixes and was later added to Linux.  Because it&#8217;s not easy to add members to well-known structures and preserve binary compatibility, OpenSolaris and Solaris lack this field, as well as the <code>DT_*</code> constant definitions.  (If <code>d_type</code> were to become part of the Unix standards, Solaris would likely have to introduce a second family of <code>opendir()</code>/<code>readdir()</code>/<code>closedir()</code> functions and a second version of the structure, similar to how large files were introduced for 32-bit programs.)</p><p>Because we fail at compilation time, our workaround has to modify either the program&#8217;s source code or its build environment.  (Preloading is too late.)  It&#8217;s probably possible to combine a few definitions and a shared object that we include via <code>LD_PRELOAD</code> but it seems easier to just provide a C wrapper around <code>readdir</code>(3C) and an alternate <code>struct dirent</code>.  We develop this approach in the next section.</p><h2><code>DIRENT</code> and <code>READDIR</code></h2><p>The approach we take is</p><ol><li>Introduce <code>DIRENT</code> and <code>READDIR</code> via <code>adirent.h</code>.</li><li>Change the source program such that each call to <code>readdir()</code> is replaced by <code>READDIR()</code> and each use of <code>struct dirent</code> is replaced by <code>DIRENT</code>.  In each file so modified, add a <code>#include &lt;adirent.h&gt;</code>.</li><li>Compile adirent.c via <code>gcc -I. -O2 -c adirent.c</code> or equivalent.</li><li>Add <code>adirent.o</code> to the link line for each binary that includes one of the files modified in step 2.</li></ol><p>If we apply these steps to our example above, we get</p><pre><code>#include &lt;sys/types.h&gt;
#include &lt;adirent.h&gt;
#include &lt;err.h&gt;
#include &lt;stdio.h&gt;

int
main(int argc, char *argv[])
{
        DIR *d;
        DIRENT *e;

        if ((d = opendir("/")) == NULL)
                err(1, "opendir failed");

        for (e = READDIR(d); e != NULL; e = READDIR(d)) {
                    if (e-&gt;d_type != DT_UNKNOWN)
                        (void) printf("recognized filetype for '%s'\n",
                            e-&gt;d_name);
        }

        (void) closedir(d);

        return (0);
 }
</code></pre><p>with the result that compilation and execution now work</p><pre><code>$ gcc -O2 -I. -c adirent.c
$ gcc -I. a.c adirent.o
$ ./a.out
</code></pre><p>This shim function and definitions should be sufficient for most ports around this incompatibility, but there are some additional comments worth making.</p><p><em>Performance.</em> Because many programs expect <code>d_type</code> to be one of <code>DT_REG</code> or <code>DT_DIR</code> to save on a <code>stat</code>(2) call, this shim will force those programs into an alleged &#8220;slow&#8221; path.  The actual impact of returning <code>DT_UNKNOWN</code> on every call will be program- and situation-dependent; it didn&#8217;t seem to affect my mail indexing.</p><p><em>Multithreaded programs.</em> The current implementation does not protect the static structure defined in <code>adirent.c</code>.  Programs with multiple threads performing <code>readdir</code>(3C) calls through <code>READDIR()</code> will get unexpected results.  It should be relatively straightforward to dynamically allocate one <code>struct adirent</code> for each thread coming through <code>READDIR()</code> for the first time.</p><h2>Downloads</h2><p>I suppose these should be in a repository on Bitbucket or GitHub.  For now, they&#8217;re just simple downloads:</p><ul><li><a
href="http://blueslugs.com/~sch/adirent/adirent.c" title="Function implementation">adirent.c</a></li><li><a
href="http://blueslugs.com/~sch/adirent/adirent.h" title="Header definitions">adirent.h</a></li></ul><h2>Acknowledgments</h2><p>I discussed this problem with <a
href="http://blogs.sun.com/dp">Dan</a>, who in particular noted that <code>DT_UNKNOWN</code> was always a legal return value for <code>d_type</code>. <a
href="http://blogs.sun.com/barts">Bart</a> looked over my shoulder and spied at least one error during the debugging phase.</p> <img
src="http://blueslugs.com/wordpress/?ak_action=api_record_view&id=31588&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://blueslugs.com/wordpress/2010/06/13/adirent-ch-adding-d_type-to-struct-dirent-on-opensolaris/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>~4100MiB</title><link>http://blueslugs.com/wordpress/2008/04/26/4100mib/</link> <comments>http://blueslugs.com/wordpress/2008/04/26/4100mib/#comments</comments> <pubDate>Sat, 26 Apr 2008 19:30:12 +0000</pubDate> <dc:creator>Stephen</dc:creator> <category><![CDATA[Observations]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[2008.05]]></category> <category><![CDATA[bittorrent]]></category> <category><![CDATA[opensolaris]]></category><guid
isPermaLink="false">http://blueslugs.com/wordpress/index.php/archives/2008/04/26/4100mib/</guid> <description><![CDATA[I seeded the 2008.05 release candidate for about 45 hours, ultimately shipping a little over 4100 megabytes. I&#8217;m going to take a break, because I want to update my DP2-based workstation and get some work done, but, once we have new bits, I&#8217;ll getting seeding again. (I found the actual result: 4237MiB sent up, so [...]]]></description> <content:encoded><![CDATA[<p>I seeded the 2008.05 release candidate for about 45 hours, ultimately shipping a little over 4100 megabytes.  I&#8217;m going to take a break, because I want to update my DP2-based workstation and get some work done, but, once we have new bits, I&#8217;ll getting seeding again.</p><p>(I found the actual result: 4237MiB sent up, so almost 4GiB.)</p> <img
src="http://blueslugs.com/wordpress/?ak_action=api_record_view&id=501&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://blueslugs.com/wordpress/2008/04/26/4100mib/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Stopping Firefox&#8217;s restore session dialog</title><link>http://blueslugs.com/wordpress/2007/12/06/stopping-firefoxs-restore-session-dialog/</link> <comments>http://blueslugs.com/wordpress/2007/12/06/stopping-firefoxs-restore-session-dialog/#comments</comments> <pubDate>Thu, 06 Dec 2007 17:47:43 +0000</pubDate> <dc:creator>Stephen</dc:creator> <category><![CDATA[Software]]></category> <category><![CDATA[efficiently]]></category><guid
isPermaLink="false">http://blueslugs.com/wordpress/index.php/archives/2007/12/06/stopping-firefoxs-restore-session-dialog/</guid> <description><![CDATA[I&#8217;m sure that there are Firefox users out there who want to restore their previous session; I never do, and so deactivating that dialog is a big timesaver. If you search, you&#8217;ll find a few writeups on how to adjust the configuration, but I want to document the minimum steps to suppress the restore session [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;m sure that there are Firefox users out there who want to restore their previous session; I never do, and so deactivating that dialog is a big timesaver.  If you search, you&#8217;ll find a few writeups on how to adjust the configuration, but I want to document the minimum steps to suppress the restore session dialog.</p><ol><li>Enter <code>about:config</code> into the URL field.</li><li>Enter <code>sessionstore</code> into the displayed filter field and press Enter.</li><li>Double-click the value cell of the <code>browser.sessionstore.enabled</code> row, so that the value field reads <code>False</code>.</li><li>Restart Firefox.  One click saved.</li></ol><p
class="tag"> [ <i>T</i>: <a
href="http://www.technorati.com/tag/Firefox" rel="tag">Firefox</a> ]</p> <img
src="http://blueslugs.com/wordpress/?ak_action=api_record_view&id=474&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://blueslugs.com/wordpress/2007/12/06/stopping-firefoxs-restore-session-dialog/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Periodic reducation of email interrupt rate</title><link>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate/</link> <comments>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate/#comments</comments> <pubDate>Wed, 11 Oct 2006 20:23:37 +0000</pubDate> <dc:creator>Stephen</dc:creator> <category><![CDATA[Observations]]></category> <category><![CDATA[Software]]></category><guid
isPermaLink="false">http://blueslugs.com/wordpress/?p=332</guid> <description><![CDATA[At work, I&#8217;ve ended up on many email aliases; since we moved to pursuing open development on opensolaris.org, my subscriptions and incoming email flow have grown tremendously, to the point where they were interfering with my ability to get work done. My present filter setup involves delivery to 56 inboxes. I&#8217;ve had a small email [...]]]></description> <content:encoded><![CDATA[<p> At work, I&#8217;ve ended up on many email aliases; since we moved to pursuing
open development on <a
href="http://opensolaris.org">opensolaris.org</a>, my subscriptions and
incoming email flow have grown tremendously, to the point where they
were interfering with my ability to get work done.  My present filter
setup involves delivery to 56 inboxes.</p><p> I&#8217;ve had a small email toolset built around <a
href="http://www.mutt.org/">the Mutt email client</a> (or mail user
agent (MUA) in email-speak).  My <code>.muttrc</code> includes <code>$HOME/.mailboxes</code>, which is a list of the mail inboxes into
which my <code>procmail</code> filter delivers.  The <code>m</code> and <code>check</code> commands use <code>.mailboxes</code> to determine
where new messages have arrived.  Happily, this infrastructure can
easily give me a few hours of reduced interrupts, so that I can get some
thinking and writing done.</p><p> The idea is to strongly reduce the number of significant inboxes during
what we&#8217;ll label as &#8220;prime&#8221; work hours, between lunch and dinner on
weekdays.  Given the use of <code>.mailboxes</code> outlined above, the
solution is pretty easy:<ol><li> Move <code>.mailboxes</code> to <code>.mailboxes.offprime</code>.</li><li> Take a copy of <code>.mailboxes.offprime</code> as <code>.mailboxes.prime</code>.  Prune the prime mailboxes severely.</li><li> Install these files in <code>$HOME</code>.  (My Makefiles do this,
and all the mailbox lists and the Makefiles are
version-controlled.)</li><li> Add something like the following using <code>crontab -e</code>:<pre>
# We want to eliminate mail testing on all mailboxes during prime work
# hours.  This change means that between 12pm - 6pm, mailboxes is
# pointed to a reduced mailboxes file.
0 12 * * 1,2,3,4,5 /usr/bin/ln -sf /home/sch/.mailboxes.prime /home/sch/.mailboxes
0 18 * * 1,2,3,4,5 /usr/bin/ln -sf /home/sch/.mailboxes.offprime /home/sch/.mailboxes
</pre></li><li> Run whichever of the two <code>ln</code>(1) invocations above
correspond to the current time.</li></ol></p><p> You&#8217;re now ready to relax and enjoy reduced interrupt rates, leaving you
time to focus on real work&#8230; or write blog postings about managing your
interrupt rates.</p><p
class="tag"> [ <i>T</i>: <a
href="http://www.technorati.com/tag/OpenSolaris" rel="tag">OpenSolaris</a> <a
href="http://www.technorati.com/tag/Solaris" rel="tag">Solaris</a> <a
href="http://www.technorati.com/tag/mutt" rel="tag">mutt</a> <a
href="http://www.technorati.com/tag/procmail" rel="tag">procmail</a> ]</p> <img
src="http://blueslugs.com/wordpress/?ak_action=api_record_view&id=332&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Periodic reducation of email interrupt rate</title><link>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate-2/</link> <comments>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate-2/#comments</comments> <pubDate>Wed, 11 Oct 2006 20:22:58 +0000</pubDate> <dc:creator>Stephen</dc:creator> <category><![CDATA[Observations]]></category> <category><![CDATA[Software]]></category><guid
isPermaLink="false">http://blueslugs.com/wordpress/index.php/archives/2006/10/11/periodic-reducation-of-email-interrupt-rate-2/</guid> <description><![CDATA[At work, I&#8217;ve ended up on many email aliases; since we moved to pursuing open development on opensolaris.org, my subscriptions and incoming email flow have grown tremendously, to the point where they were interfering with my ability to get work done. My present filter setup involves delivery to 56 inboxes. I&#8217;ve had a small email [...]]]></description> <content:encoded><![CDATA[<p> At work, I&#8217;ve ended up on many email aliases; since we moved to pursuing
open development on <a
href="http://opensolaris.org">opensolaris.org</a>, my subscriptions and
incoming email flow have grown tremendously, to the point where they
were interfering with my ability to get work done.  My present filter
setup involves delivery to 56 inboxes.</p><p> I&#8217;ve had a small email toolset built around <a
href="http://www.mutt.org/">the Mutt email client</a> (or mail user
agent (MUA) in email-speak).  My <code>.muttrc</code> includes <code>$HOME/.mailboxes</code>, which is a list of the mail inboxes into
which my <code>procmail</code> filter delivers.  The <code>m</code> and <code>check</code> commands use <code>.mailboxes</code> to determine
where new messages have arrived.  Happily, this infrastructure can
easily give me a few hours of reduced interrupts, so that I can get some
thinking and writing done.</p><p> The idea is to strongly reduce the number of significant inboxes during
what we&#8217;ll label as &#8220;prime&#8221; work hours, between lunch and dinner on
weekdays.  Given the use of <code>.mailboxes</code> outlined above, the
solution is pretty easy:<ol><li> Move <code>.mailboxes</code> to <code>.mailboxes.offprime</code>.</li><li> Take a copy of <code>.mailboxes.offprime</code> as <code>.mailboxes.prime</code>.  Prune the prime mailboxes severely.</li><li> Install these files in <code>$HOME</code>.  (My Makefiles do this,
and all the mailbox lists and the Makefiles are
version-controlled.)</li><li> Add something like the following using <code>crontab -e</code>:<pre>
# We want to eliminate mail testing on all mailboxes during prime work
# hours.  This change means that between 12pm - 6pm, mailboxes is
# pointed to a reduced mailboxes file.
0 12 * * 1,2,3,4,5 /usr/bin/ln -sf /home/sch/.mailboxes.prime /home/sch/.mailboxes
0 18 * * 1,2,3,4,5 /usr/bin/ln -sf /home/sch/.mailboxes.offprime /home/sch/.mailboxes
</pre></li><li> Run whichever of the two <code>ln</code>(1) invocations above
correspond to the current time.</li></ol></p><p> You&#8217;re now ready to relax and enjoy reduced interrupt rates, leaving you
time to focus on real work&#8230; or write blog postings about managing your
interrupt rates.</p><p
class="tag"> [ <i>T</i>: <a
href="http://www.technorati.com/tag/OpenSolaris" rel="tag">OpenSolaris</a> <a
href="http://www.technorati.com/tag/Solaris" rel="tag">Solaris</a> <a
href="http://www.technorati.com/tag/mutt" rel="tag">mutt</a> <a
href="http://www.technorati.com/tag/procmail" rel="tag">procmail</a> ]</p> <img
src="http://blueslugs.com/wordpress/?ak_action=api_record_view&id=331&type=feed" alt="" />]]></content:encoded> <wfw:commentRss>http://blueslugs.com/wordpress/2006/10/11/periodic-reducation-of-email-interrupt-rate-2/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)

Served from: blueslugs.com @ 2010-07-30 11:54:21 -->