339 lines
5.7 KiB
HTML
339 lines
5.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Design</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
|
REL="HOME"
|
|
TITLE="Pocket Linux Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Filling in the Gaps"
|
|
HREF="phase7.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Analysis"
|
|
HREF="x1563.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Construction"
|
|
HREF="x1654.html"></HEAD
|
|
><BODY
|
|
CLASS="sect1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
SUMMARY="Header navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Pocket Linux Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x1563.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 8. Filling in the Gaps</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x1654.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="sect1"
|
|
><H1
|
|
CLASS="sect1"
|
|
><A
|
|
NAME="AEN1601"
|
|
></A
|
|
>8.2. Design</H1
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN1603"
|
|
></A
|
|
>8.2.1. more</H2
|
|
><P
|
|
>There is a <B
|
|
CLASS="command"
|
|
>more</B
|
|
> command that comes with
|
|
util-linux, but it will not work for this project. The reason is because
|
|
of library dependencies and space constraints. The util-linux supplied
|
|
<B
|
|
CLASS="command"
|
|
>more</B
|
|
> needs either the libncurses or libtermcap to
|
|
work and there just is not enough space on the root disk floppy to fit
|
|
everything in. So, in order to have a <B
|
|
CLASS="command"
|
|
>more</B
|
|
> command we
|
|
will have to get creative.</P
|
|
><P
|
|
>The <B
|
|
CLASS="command"
|
|
>more</B
|
|
> command is used to display a file page
|
|
by page. It's a little like having a <B
|
|
CLASS="command"
|
|
>cat</B
|
|
> command that
|
|
pauses every twenty-five lines. The basic logic is outlined
|
|
below.</P
|
|
><P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
>Read one line of the file.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Display the line on the screen.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>If 25 lines have been displayed, pause.</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
>Loop and do it again.</P
|
|
></LI
|
|
></UL
|
|
><P
|
|
>Of course there are some details left out like what to do if the
|
|
screen dimensions are not what we anticipated, but overall it is a fair
|
|
representation of what <B
|
|
CLASS="command"
|
|
>more</B
|
|
> does. Given this simple
|
|
program logic, it should not be hard to put together a short shell
|
|
script that emulates the basic functionality of <B
|
|
CLASS="command"
|
|
>more</B
|
|
>.
|
|
The BASH(1) manpage and Adv-BASH-Scripting-Guide will serve as
|
|
references.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN1624"
|
|
></A
|
|
>8.2.2. More device files</H2
|
|
><P
|
|
>The <B
|
|
CLASS="command"
|
|
>more</B
|
|
> script will need access to device
|
|
files that are not on the root disk yet. Specifically
|
|
<B
|
|
CLASS="command"
|
|
>more</B
|
|
> needs to have <TT
|
|
CLASS="filename"
|
|
>stdin</TT
|
|
>,
|
|
<TT
|
|
CLASS="filename"
|
|
>stdout</TT
|
|
> and <TT
|
|
CLASS="filename"
|
|
>stderr</TT
|
|
>, but while
|
|
we are at it we should check for any other missing
|
|
<TT
|
|
CLASS="filename"
|
|
>/dev</TT
|
|
> files. The Linux Standard Base requires
|
|
<TT
|
|
CLASS="filename"
|
|
>null</TT
|
|
>, <TT
|
|
CLASS="filename"
|
|
>zero</TT
|
|
> and
|
|
<TT
|
|
CLASS="filename"
|
|
>tty</TT
|
|
> to be present in the <TT
|
|
CLASS="filename"
|
|
>/dev</TT
|
|
>
|
|
directory. Files for <TT
|
|
CLASS="filename"
|
|
>null</TT
|
|
> and
|
|
<TT
|
|
CLASS="filename"
|
|
>tty</TT
|
|
> already exist from previous phases of the
|
|
project, but we still need <TT
|
|
CLASS="filename"
|
|
>/dev/zero</TT
|
|
>. We can refer
|
|
to <TT
|
|
CLASS="filename"
|
|
>devices.txt</TT
|
|
> in the Linux source code
|
|
<TT
|
|
CLASS="filename"
|
|
>Documentation</TT
|
|
> directory for major and minor
|
|
numbers.</P
|
|
></DIV
|
|
><DIV
|
|
CLASS="sect2"
|
|
><H2
|
|
CLASS="sect2"
|
|
><A
|
|
NAME="AEN1642"
|
|
></A
|
|
>8.2.3. ps, sed & ed</H2
|
|
><P
|
|
>These three packages can be found by using the Internet resources
|
|
we have used before plus one new site. The "sed" and "ed" packages can
|
|
be found at the same place we found BASH, on the <A
|
|
HREF="ftp://ftp.gnu.org"
|
|
TARGET="_top"
|
|
>GNU FTP server</A
|
|
>. The procps package shows
|
|
up in an Ibiblio LSM search, but it is an old version. In order to find
|
|
the latest version we can go to the Freshmeat website at <A
|
|
HREF="http://freshmeat.net"
|
|
TARGET="_top"
|
|
>http://freshmeat.net</A
|
|
> and search for
|
|
"procps" in projects.</P
|
|
><P
|
|
>Both "sed" and "ed" packages feature GNU's familiar
|
|
<B
|
|
CLASS="command"
|
|
>configure</B
|
|
> script and are therefore very easy to
|
|
build. There is no <B
|
|
CLASS="command"
|
|
>configure</B
|
|
> script for "procps" but
|
|
this does not make things too difficult. We can just read the package's
|
|
<TT
|
|
CLASS="filename"
|
|
>README</TT
|
|
> file to find out about how to set various
|
|
configuration options. We can use one of these options to avoid the
|
|
complexity of using and installing libproc. Setting
|
|
<TT
|
|
CLASS="parameter"
|
|
><I
|
|
>SHARED=0</I
|
|
></TT
|
|
> makes <TT
|
|
CLASS="filename"
|
|
>libproc</TT
|
|
> an
|
|
integrated part of <B
|
|
CLASS="command"
|
|
>ps</B
|
|
> rather than a separate, shared
|
|
library.</P
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
SUMMARY="Footer navigation table"
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x1563.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
ACCESSKEY="H"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x1654.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Analysis</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="phase7.html"
|
|
ACCESSKEY="U"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Construction</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |