old-tour.html revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
98N/A<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
98N/A<HTML>
287N/A<HEAD>
98N/A<META NAME="generator" CONTENT="troff2html (AT&T Labs Research) 04/01/97 -mm">
98N/A<TITLE>tour.mm mm document</TITLE>
98N/A</HEAD>
98N/A<BODY>
98N/A<PRE><CENTER><H2>A Tour of the ast Commands and Libraries</H2><H4>
98N/AGlenn Fowler
98N/A
98N/AAT&amp;T Labs - Research
98N/A
98N/AMurray Hill, NJ 07974
98N/A
98N/A</H4></CENTER>
98N/A</PRE><DL COMPACT>
98N/A<DT>
98N/A<HR>
98N/A<H3><A NAME="1Introduction">1&nbsp;&nbsp;Introduction</A></H3>
98N/A<DD></DL>
98N/AThe <EM>ast </EM>commands and libraries were developed by the Software Engineering
98N/AResearch Department (<EM>aka </EM>the Advanced Software [Technology] Department)
98N/Aat AT&amp;T Bell Laboratories, Murray Hill, NJ.
98N/AThe strength of <EM>ast </EM>is how its individual components combine to form a
98N/Acohesive computing environment across UNIX<SUP>&#174;</SUP> and non-UNIX platforms.
98N/A<A HREF="#FN577">Cohesiveness*</A><FN ID="FN577">Footnote test.
98N/A</FN>is maintained by well-defined library interfaces for algorithms upon which
98N/Athe commands are built.
98N/AIn many cases a library implementation was the driving force behind command
98N/Aimplementations.
543N/A<DL COMPACT>
98N/A<DT>
98N/A<HR>
98N/A<H3><A NAME="2Motivation">2&nbsp;&nbsp;Motivation</A></H3>
354N/A<DD></DL>
354N/AWhy should you consider using the <EM>ast </EM>software? After all, many of the
354N/Acommands look like what's already in <TT>/bin </TT>and <TT>/usr/local/gnu/bin</TT>.
354N/AAlthough there is some replication, there are also some commands you won't
354N/Afind anywhere else: <EM>the </EM>ksh93, nmake, the 3d filesystem, cia, and yeast.
354N/A<DL COMPACT>
354N/A<DT>
354N/A<HR>
354N/A<H3><A NAME="3Installation">3&nbsp;&nbsp;Installation</A></H3>
354N/A<DD></DL>
354N/AThe <EM>ast </EM>software installs in a single directory hierarchy, rooted at <TT>$INSTALLROOT</TT>,
354N/Ausually <TT>/usr/local/ast </TT>or <TT>/usr/add-on/ast</TT>.
98N/AThe top level <TT>$INSTALLROOT </TT>directories are: <PRE>
98N/A<TT> bin executable binaries and scripts
98N/A fun </TT><EM>ksh93</EM><TT> shell functions
98N/A lib libraries
98N/A lib/</TT><EM>command</EM><TT> related files for </TT><EM>command</EM><TT>
98N/A src/cmd/</TT><EM>xxx</EM><TT> source for command </TT><EM>xxx</EM><TT>
341N/A src/lib/lib</TT><EM>xxx</EM><TT> source for library </TT><EM>xxx</EM><TT>
366N/A</TT></PRE>To access the commands and related data files: <PRE>
354N/A<TT> export PATH=$INSTALLROOT/bin:$PATH
425N/A</TT></PRE>For each <EM>command </EM>that has a related data file <EM>file</EM>, <EM>file </EM>is found by searching
325N/A<TT>$PATH </TT>for e.g., the magic file for the file command is <TT>/lib/file/magic
456N/A</TT>on <TT>$PATH</TT>.
325N/AIf <TT>$HOME/bin </TT>is before <TT>$INSTALLROOT/bin </TT>in <TT>$PATH </TT>then you can selectively
354N/Aoverride standard <EM>ast </EM>related files by placing them in the directory This
278N/Aallows executables to be built without hard-coded pathnames and also requires
98N/Aonly a change in <TT>$PATH </TT>when <TT>$INSTALLROOT </TT>changes.
543N/AOn systems with shared libraries one of <PRE>
98N/A<TT> export LD_LIBRARY_PATH=$INSTALLROOT/lib:$LD_LIBRARY_PATH
98N/A export LIBPATH=$INSTALLROOT/lib:$LIBPATH
151N/A export LPATH=$INSTALLROOT/lib:$LPATH
137N/A</TT></PRE>is required to locate the <EM>ast </EM>shared libraries.
153N/A<DL COMPACT>
210N/A<P>
366N/A<DT>
98N/A<HR>
179N/A<H3><A NAME="4Exploration">4&nbsp;&nbsp;Exploration</A></H3>
269N/A<DD><EM>tw </EM></DL>
126N/Acombines <EM>find </EM>and <EM>xargs</EM>.
98N/AIt provides C style expressions on path names and elements of <TT>struct stat</TT>.
98N/ATo find suspicious executables: <PRE>
543N/A<TT> tw -d / -e "uid=='root' &amp;&amp; (mode&amp;'u+s') &amp;&amp; parent.uid!=uid"
543N/A</TT></PRE>to change the owner of all of bozo's files: <PRE>
98N/A<TT> tw -d / -e "uid=='bozo'" chown clown:circus
287N/A</TT></PRE><EM>tw </EM>collects file pathname arguments up to the exec arg limit before it
366N/Aexecutes the command.
499N/AFor paranoid users: <PRE>
123N/A<TT> tw chmod go-rwx
98N/A</TT></PRE>which is equivalent to: <PRE>
98N/A<TT> chmod -R go-rwx
98N/A</TT></PRE>(Now you don't need to add a <TT>-R </TT>option to your favorite commands.) To find
98N/Aall source files that include <TT>foo.h</TT>: <PRE>
498N/A<TT> tw -e "name=='*.[chly]'" grep -l '^#.*include.*["&lt;]foo.h[&gt;"]'
498N/A</TT></PRE><EM>libast </EM>handles the magic number matching for the <EM>file </EM>command.
98N/AThe magic file, <TT>$INSTALLROOT/lib/file/magic</TT>, is carefully constructed to
98N/Agive the same output across all architectures: <PRE>
98N/A<TT> cd $HOME/arch
98N/A file */bin/cat
98N/A</TT></PRE>might produce: <PRE>
98N/A<TT> att.i386/bin/cat: elf i386 executable, 32-bit, little-endian, ..
98N/A bsd.i386/bin/cat: bsd 386 executable, compact, paged, pure, no..
493N/A hp.pa/bin/cat: hp pa-risc executable, shared, dynamically l..
493N/A sgi.mips2/bin/cat: elf mips executable, 32-bit, dynamically lin..
98N/A sol.sun4/bin/cat: elf sparc executable, 32-bit, dynamically li..
493N/A sun4/bin/cat: sun sparc executable, paged, dynamically lin..
493N/A</TT></PRE><EM>tw </EM>uses the same interface, making it easy to search for files based on
493N/Atype, name and content.
The following searches for executable scripts: <PRE>
<TT> tw -e "(mode&amp;'+x') &amp;&amp; type!=DIR &amp;&amp; magic!='*executable*'"
</TT></PRE>The <EM>tw </EM>algorithm efficiently detects file system loops, so following symbolic
links is not a problem.
The same algorithm is used by all <EM>ast </EM>commands that traverse directory
hierarchies, and the following options to control pathname resolution:
<PRE><TT> -L (logical) follow symbolic links
-P (physical) don't follow symbolic links
-H (metaphysical) -L for command line files, -P otherwise
</TT></PRE>The <EM>ksh93 </EM><EM>getconf </EM>builtin controls the default traversal mode: <PRE>
<TT> getconf PATH_RESOLVE - { logical, physical, metaphysical }
</TT></PRE><DL COMPACT>
<DT>
<HR>
<H3><A NAME="5Configuration">5&nbsp;&nbsp;Configuration</A></H3>
<DD><DT>
<HR>
<H3><A NAME="6Compression">6&nbsp;&nbsp;Compression</A></H3>
<DD><DT>
<HR>
<H3><A NAME="7Conclusion">7&nbsp;&nbsp;Conclusion</A></H3>
<DD></DL>
<HR>
<P>April 18, 1997
</BODY></HTML>