summaryrefslogtreecommitdiff
path: root/release/src/router/busybox/examples
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 12:04:58 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2015-01-03 12:04:58 +0100
commit008d0be72b2f160382c6e880765e96b64a050c65 (patch)
tree36f48a98a3815a408e2ce1693dd182af90f80305 /release/src/router/busybox/examples
parent611becfb8726c60cb060368541ad98191d4532f5 (diff)
downloadtomato-008d0be72b2f160382c6e880765e96b64a050c65.tar.gz
tomato-008d0be72b2f160382c6e880765e96b64a050c65.tar.bz2
imported original firmware WRT54GL_v4.30.11_11_US
Diffstat (limited to 'release/src/router/busybox/examples')
-rw-r--r--release/src/router/busybox/examples/bootfloppy/bootfloppy.txt180
-rw-r--r--release/src/router/busybox/examples/bootfloppy/display.txt4
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/etc/fstab2
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/etc/inittab5
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/etc/profile8
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/mkdevs.sh62
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/mkrootfs.sh105
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/mksyslinux.sh48
-rw-r--r--release/src/router/busybox/examples/bootfloppy/quickstart.txt15
-rwxr-xr-xrelease/src/router/busybox/examples/bootfloppy/syslinux.cfg7
-rwxr-xr-xrelease/src/router/busybox/examples/busybox.spec44
-rwxr-xr-xrelease/src/router/busybox/examples/depmod.pl237
-rwxr-xr-xrelease/src/router/busybox/examples/inittab90
-rwxr-xr-xrelease/src/router/busybox/examples/mk2knr.pl84
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/sample.bound30
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/sample.deconfig4
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/sample.nak4
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/sample.renew30
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/sample.script7
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/simple.script39
-rwxr-xr-xrelease/src/router/busybox/examples/udhcp/udhcpd.conf116
-rwxr-xr-xrelease/src/router/busybox/examples/undeb53
-rwxr-xr-xrelease/src/router/busybox/examples/unrpm48
23 files changed, 1222 insertions, 0 deletions
diff --git a/release/src/router/busybox/examples/bootfloppy/bootfloppy.txt b/release/src/router/busybox/examples/bootfloppy/bootfloppy.txt
new file mode 100644
index 00000000..090ef049
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/bootfloppy.txt
@@ -0,0 +1,180 @@
+Building a Busybox Boot Floppy
+==============================
+
+This document describes how to buid a boot floppy using the following
+components:
+
+ - Linux Kernel (http://www.kernel.org)
+ - uClibc: C library (http://cvs.uclinux.org/uClibc.html)
+ - Busybox: Unix utilities (http://busybox.net/)
+ - Syslinux: bootloader (http://syslinux.zytor.com)
+
+It is based heavily on a paper presented by Erik Andersen at the 2001 Embedded
+Systems Conference.
+
+
+
+Building The Software Components
+--------------------------------
+
+Detailed instructions on how to build Busybox, uClibc, or a working Linux
+kernel are beyond the scope of this document. The following guidelines will
+help though:
+
+ - Stock Busybox from CVS or a tarball will work with no modifications to
+ any files. Just extract and go.
+ - Ditto uClibc.
+ - Your Linux kernel must include support for initrd or else the floppy
+ won't be able to mount it's root file system.
+
+If you require further information on building Busybox uClibc or Linux, please
+refer to the web pages and documentation for those individual programs.
+
+
+
+Making a Root File System
+-------------------------
+
+The following steps will create a root file system.
+
+ - Create an empty file that you can format as a filesystem:
+
+ dd if=/dev/zero of=rootfs bs=1k count=4000
+
+ - Set up the rootfs file we just created to be used as a loop device (may not
+ be necessary)
+
+ losetup /dev/loop0 rootfs
+
+ - Format the rootfs file with a filesystem:
+
+ mkfs.ext2 -F -i 2000 rootfs
+
+ - Mount the file on a mountpoint so we can place files in it:
+
+ mkdir loop
+ mount -o loop rootfs loop/
+
+ (you will probably need to be root to do this)
+
+ - Copy on the C library, the dynamic linking library, and other necessary
+ libraries. For this example, we copy the following files from the uClibc
+ tree:
+
+ mkdir loop/lib
+ (chdir to uClibc directory)
+ cp -a libc.so* uClibc*.so \
+ ld.so-1/d-link/ld-linux-uclibc.so* \
+ ld.so-1/libdl/libdl.so* \
+ crypt/libcrypt.so* \
+ (path to)loop/lib
+
+ - Install the Busybox binary and accompanying symlinks:
+
+ (chdir to busybox directory)
+ make PREFIX=(path to)loop/ install
+
+ - Make device files in /dev:
+
+ This can be done by running the 'mkdevs.sh' script. If you want the gory
+ details, you can read the script.
+
+ - Make necessary files in /etc:
+
+ For this, just cp -a the etc/ directory onto rootfs. Again, if you want
+ all the details, you can just look at the files in the dir.
+
+ - Unmount the rootfs from the mountpoint:
+
+ umount loop
+
+ - Compress it:
+
+ gzip -9 rootfs
+
+
+Making a SYSLINUX boot floppy
+-----------------------------
+
+The following steps will create the boot floppy.
+
+Note: You will need to have the mtools package installed beforehand.
+
+ - Insert a floppy in the drive and format it with an MSDOS filesystem:
+
+ mformat a:
+
+ (if the system doesn't know what device 'a:' is, look at /etc/mtools.conf)
+
+ - Run syslinux on the floppy:
+
+ syslinux -s /dev/fd0
+
+ (the -s stands for "safe, slow, and stupid" and should work better with
+ buggy BIOSes; it can be omitted)
+
+ - Put on a syslinux.cfg file:
+
+ mcopy syslinux.cfg a:
+
+ (more on syslinux.cfg below)
+
+ - Copy the root file system you made onto the MSDOS formatted floppy
+
+ mcopy rootfs.gz a:
+
+ - Build a linux kernel and copy it onto the disk with the filename 'linux'
+
+ mcopy bzImage a:linux
+
+
+Sample syslinux.cfg
+~~~~~~~~~~~~~~~~~~~
+
+The following simple syslinux.cfg file should work. You can tweak it if you
+like.
+
+----begin-syslinux.cfg---------------
+DEFAULT linux
+APPEND initrd=rootfs.gz root=/dev/ram0
+TIMEOUT 10
+PROMPT 1
+----end-syslinux.cfg---------------
+
+Some changes you could make to syslinux.cfg:
+
+ - This value is the number seconds it will wait before booting. You can set
+ the timeout to 0 (or omit) to boot instantly, or you can set it as high as
+ 10 to wait awhile.
+
+ - PROMPT can be set to 0 to disable the 'boot:' prompt.
+
+ - you can add this line to display the contents of a file as a welcome
+ message:
+
+ DISPLAY display.txt
+
+
+
+Additional Resources
+--------------------
+
+Other useful information on making a Linux bootfloppy is available at the
+following URLs:
+
+http://www.linuxdoc.org/HOWTO/Bootdisk-HOWTO/index.html
+http://www.linux-embedded.com/howto/Embedded-Linux-Howto.html
+http://linux-embedded.org/howto/LFS-HOWTO.html
+http://linux-embedded.org/pmhowto.html
+http://recycle.lbl.gov/~ldoolitt/embedded/ (Larry Doolittle's stuff)
+
+
+
+Possible TODOs
+--------------
+
+The following features that we might want to add later:
+
+ - support for additional filesystems besides ext2, i.e. minix
+ - different libc, static vs dynamic loading
+ - maybe using an alternate bootloader
diff --git a/release/src/router/busybox/examples/bootfloppy/display.txt b/release/src/router/busybox/examples/bootfloppy/display.txt
new file mode 100644
index 00000000..399d326d
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/display.txt
@@ -0,0 +1,4 @@
+
+This boot floppy is made with Busybox, uClibc, and the Linux kernel.
+Hit RETURN to boot or enter boot parameters at the prompt below.
+
diff --git a/release/src/router/busybox/examples/bootfloppy/etc/fstab b/release/src/router/busybox/examples/bootfloppy/etc/fstab
new file mode 100755
index 00000000..ef14ca2c
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/etc/fstab
@@ -0,0 +1,2 @@
+proc /proc proc defaults 0 0
+
diff --git a/release/src/router/busybox/examples/bootfloppy/etc/inittab b/release/src/router/busybox/examples/bootfloppy/etc/inittab
new file mode 100755
index 00000000..eb3e979c
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/etc/inittab
@@ -0,0 +1,5 @@
+::sysinit:/etc/init.d/rcS
+::respawn:-/bin/sh
+tty2::askfirst:-/bin/sh
+::ctrlaltdel:/bin/umount -a -r
+
diff --git a/release/src/router/busybox/examples/bootfloppy/etc/profile b/release/src/router/busybox/examples/bootfloppy/etc/profile
new file mode 100755
index 00000000..e9b11e90
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/etc/profile
@@ -0,0 +1,8 @@
+# /etc/profile: system-wide .profile file for the Bourne shells
+
+echo
+echo -n "Processing /etc/profile... "
+# no-op
+echo "Done"
+echo
+
diff --git a/release/src/router/busybox/examples/bootfloppy/mkdevs.sh b/release/src/router/busybox/examples/bootfloppy/mkdevs.sh
new file mode 100755
index 00000000..03a1a855
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/mkdevs.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# makedev.sh - creates device files for a busybox boot floppy image
+
+
+# we do our work in the dev/ directory
+if [ -z "$1" ]; then
+ echo "usage: `basename $0` path/to/dev/dir"
+ exit 1
+fi
+
+cd $1
+
+
+# miscellaneous one-of-a-kind stuff
+mknod console c 5 1
+mknod full c 1 7
+mknod kmem c 1 2
+mknod mem c 1 1
+mknod null c 1 3
+mknod port c 1 4
+mknod random c 1 8
+mknod urandom c 1 9
+mknod zero c 1 5
+ln -s /proc/kcore core
+
+# IDE HD devs
+# note: not going to bother creating all concievable partitions; you can do
+# that yourself as you need 'em.
+mknod hda b 3 0
+mknod hdb b 3 64
+mknod hdc b 22 0
+mknod hdd b 22 64
+
+# loop devs
+for i in `seq 0 7`; do
+ mknod loop$i b 7 $i
+done
+
+# ram devs
+for i in `seq 0 9`; do
+ mknod ram$i b 1 $i
+done
+ln -s ram1 ram
+
+# ttys
+mknod tty c 5 0
+for i in `seq 0 9`; do
+ mknod tty$i c 4 $i
+done
+
+# virtual console screen devs
+for i in `seq 0 9`; do
+ mknod vcs$i b 7 $i
+done
+ln -s vcs0 vcs
+
+# virtual console screen w/ attributes devs
+for i in `seq 0 9`; do
+ mknod vcsa$i b 7 $i
+done
+ln -s vcsa0 vcsa
diff --git a/release/src/router/busybox/examples/bootfloppy/mkrootfs.sh b/release/src/router/busybox/examples/bootfloppy/mkrootfs.sh
new file mode 100755
index 00000000..e56d1046
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/mkrootfs.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+#
+# mkrootfs.sh - creates a root file system
+#
+
+# TODO: need to add checks here to verify that busybox, uClibc and bzImage
+# exist
+
+
+# command-line settable variables
+BUSYBOX_DIR=..
+UCLIBC_DIR=../../uClibc
+TARGET_DIR=./loop
+FSSIZE=4000
+CLEANUP=1
+MKFS='mkfs.ext2 -F'
+
+# don't-touch variables
+BASE_DIR=`pwd`
+
+
+while getopts 'b:u:s:t:Cm' opt
+do
+ case $opt in
+ b) BUSYBOX_DIR=$OPTARG ;;
+ u) UCLIBC_DIR=$OPTARG ;;
+ t) TARGET_DIR=$OPTARG ;;
+ s) FSSIZE=$OPTARG ;;
+ C) CLEANUP=0 ;;
+ m) MKFS='mkfs.minix' ;;
+ *)
+ echo "usage: `basename $0` [-bu]"
+ echo " -b DIR path to busybox direcory (default ..)"
+ echo " -u DIR path to uClibc direcory (default ../../uClibc)"
+ echo " -t DIR path to target direcory (default ./loop)"
+ echo " -s SIZE size of root filesystem in Kbytes (default 4000)"
+ echo " -C don't perform cleanup (umount target dir, gzip rootfs, etc.)"
+ echo " (this allows you to 'chroot loop/ /bin/sh' to test it)"
+ echo " -m use minix filesystem (default is ext2)"
+ exit 1
+ ;;
+ esac
+done
+
+
+
+
+# clean up from any previous work
+mount | grep -q loop
+[ $? -eq 0 ] && umount $TARGET_DIR
+[ -d $TARGET_DIR ] && rm -rf $TARGET_DIR/
+[ -f rootfs ] && rm -f rootfs
+[ -f rootfs.gz ] && rm -f rootfs.gz
+
+
+# prepare root file system and mount as loopback
+dd if=/dev/zero of=rootfs bs=1k count=$FSSIZE
+$MKFS -i 2000 rootfs
+mkdir $TARGET_DIR
+mount -o loop,exec rootfs $TARGET_DIR # must be root
+
+
+# install uClibc
+mkdir -p $TARGET_DIR/lib
+cd $UCLIBC_DIR
+make INSTALL_DIR=
+cp -a libc.so* $BASE_DIR/$TARGET_DIR/lib
+cp -a uClibc*.so $BASE_DIR/$TARGET_DIR/lib
+cp -a ld.so-1/d-link/ld-linux-uclibc.so* $BASE_DIR/$TARGET_DIR/lib
+cp -a ld.so-1/libdl/libdl.so* $BASE_DIR/$TARGET_DIR/lib
+cp -a crypt/libcrypt.so* $BASE_DIR/$TARGET_DIR/lib
+cd $BASE_DIR
+
+
+# install busybox and components
+cd $BUSYBOX_DIR
+make distclean
+make CC=$BASE_DIR/$UCLIBC_DIR/extra/gcc-uClibc/i386-uclibc-gcc
+make PREFIX=$BASE_DIR/$TARGET_DIR install
+cd $BASE_DIR
+
+
+# make files in /dev
+mkdir $TARGET_DIR/dev
+./mkdevs.sh $TARGET_DIR/dev
+
+
+# make files in /etc
+cp -a etc $TARGET_DIR
+ln -s /proc/mounts $TARGET_DIR/etc/mtab
+
+
+# other miscellaneous setup
+mkdir $TARGET_DIR/initrd
+mkdir $TARGET_DIR/proc
+
+
+# Done. Maybe do cleanup.
+if [ $CLEANUP -eq 1 ]
+then
+ umount $TARGET_DIR
+ rmdir $TARGET_DIR
+ gzip -9 rootfs
+fi
+
diff --git a/release/src/router/busybox/examples/bootfloppy/mksyslinux.sh b/release/src/router/busybox/examples/bootfloppy/mksyslinux.sh
new file mode 100755
index 00000000..e2541735
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/mksyslinux.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Formats a floppy to use Syslinux
+
+dummy=""
+
+
+# need to have mtools installed
+if [ -z `which mformat` -o -z `which mcopy` ]; then
+ echo "You must have the mtools package installed to run this script"
+ exit 1
+fi
+
+
+# need an arg for the location of the kernel
+if [ -z "$1" ]; then
+ echo "usage: `basename $0` path/to/linux/kernel"
+ exit 1
+fi
+
+
+# need to have a root file system built
+if [ ! -f rootfs.gz ]; then
+ echo "You need to have a rootfs built first."
+ echo "Hit RETURN to make one now or Control-C to quit."
+ read dummy
+ ./mkrootfs.sh
+fi
+
+
+# prepare the floppy
+echo "Please insert a blank floppy in the drive and press RETURN to format"
+echo "(WARNING: All data will be erased! Hit Control-C to abort)"
+read dummy
+
+echo "Formatting the floppy..."
+mformat a:
+echo "Making it bootable with Syslinux..."
+syslinux -s /dev/fd0
+echo "Copying Syslinux configuration files..."
+mcopy syslinux.cfg display.txt a:
+echo "Copying root filesystem file..."
+mcopy rootfs.gz a:
+# XXX: maybe check for "no space on device" errors here
+echo "Copying linux kernel..."
+mcopy $1 a:linux
+# XXX: maybe check for "no space on device" errors here too
+echo "Finished: boot floppy created"
diff --git a/release/src/router/busybox/examples/bootfloppy/quickstart.txt b/release/src/router/busybox/examples/bootfloppy/quickstart.txt
new file mode 100644
index 00000000..0d809082
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/quickstart.txt
@@ -0,0 +1,15 @@
+Quickstart on making the Busybox boot-floppy:
+
+ 1) Download Busybox and uClibc from CVS or tarballs. Make sure they share a
+ common parent directory. (i.e. busybox/ and uclibc/ are both right off of
+ /tmp, or wherever.)
+
+ 2) Build a Linux kernel. Make sure you include support for initrd.
+
+ 3) Put a floppy in the drive. Make sure it is a floppy you don't care about
+ because the contents will be overwritten.
+
+ 4) As root, type ./mksyslinux.sh path/to/linux/kernel from this directory.
+ Wait patiently while the magic happens.
+
+ 5) Boot up on the floppy.
diff --git a/release/src/router/busybox/examples/bootfloppy/syslinux.cfg b/release/src/router/busybox/examples/bootfloppy/syslinux.cfg
new file mode 100755
index 00000000..8d407cad
--- /dev/null
+++ b/release/src/router/busybox/examples/bootfloppy/syslinux.cfg
@@ -0,0 +1,7 @@
+display display.txt
+default linux
+timeout 10
+prompt 1
+label linux
+ kernel linux
+ append initrd=rootfs.gz root=/dev/ram0
diff --git a/release/src/router/busybox/examples/busybox.spec b/release/src/router/busybox/examples/busybox.spec
new file mode 100755
index 00000000..188b09b2
--- /dev/null
+++ b/release/src/router/busybox/examples/busybox.spec
@@ -0,0 +1,44 @@
+%define name busybox
+%define epoch 0
+%define version 0.61.pre
+%define release %(date -I | sed -e 's/-/_/g')
+%define serial 1
+
+Name: %{name}
+#Epoch: %{epoch}
+Version: %{version}
+Release: %{release}
+Serial: %{serial}
+Copyright: GPL
+Group: System/Utilities
+Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
+URL: http://busybox.net/
+Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz
+Buildroot: /var/tmp/%{name}-%{version}
+Packager : Erik Andersen <andersen@codepoet.org>
+
+%Description
+BusyBox combines tiny versions of many common UNIX utilities into a single
+small executable. It provides minimalist replacements for most of the utilities
+you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
+tar, etc. BusyBox provides a fairly complete POSIX environment for any small
+or emdedded system. The utilities in BusyBox generally have fewer options then
+their full featured GNU cousins; however, the options that are provided behave
+very much like their GNU counterparts.
+
+%Prep
+%setup -q -n %{name}-%{version}
+
+%Build
+make
+
+%Install
+rm -rf $RPM_BUILD_ROOT
+make PREFIX=$RPM_BUILD_ROOT install
+
+%Clean
+rm -rf $RPM_BUILD_ROOT
+
+%Files
+%defattr(-,root,root)
+/
diff --git a/release/src/router/busybox/examples/depmod.pl b/release/src/router/busybox/examples/depmod.pl
new file mode 100755
index 00000000..c4964e7a
--- /dev/null
+++ b/release/src/router/busybox/examples/depmod.pl
@@ -0,0 +1,237 @@
+#!/usr/bin/perl -w
+# vi: set ts=4:
+# Copyright (c) 2001 David Schleef <ds@schleef.org>
+# Copyright (c) 2001 Erik Andersen <andersen@codepoet.org>
+# Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com>
+# Copyright (c) 2002 Steven J. Hill <shill@broadcom.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the same terms as Perl itself.
+
+# TODO -- use strict mode...
+#use strict;
+
+use Getopt::Long;
+use File::Find;
+
+
+# Set up some default values
+
+my $basedir="";
+my $kernel;
+my $kernelsyms;
+my $stdout=0;
+my $verbose=0;
+
+
+# get command-line options
+
+my %opt;
+
+GetOptions(
+ \%opt,
+ "help|h",
+ "basedir|b=s" => \$basedir,
+ "kernel|k=s" => \$kernel,
+ "kernelsyms|F=s" => \$kernelsyms,
+ "stdout|n" => \$stdout,
+ "verbose|v" => \$verbose,
+);
+
+if (defined $opt{help}) {
+ print
+ " $0 [OPTION]... [basedir]\n",
+ " -h --help\t\tShow this help screen\n",
+ " -b --basedir\tModules base directory (defaults to /lib/modules)\n",
+ " -k --kernel\tKernel binary for the target\n",
+ " -F --kernelsyms\tKernel symbol file\n",
+ " -n --stdout\tWrite to stdout instead of <basedir>/modules.dep\n",
+ " -v --verbose\tPrint out lots of debugging stuff\n",
+ ;
+ exit 1;
+}
+
+if($basedir !~ m-/lib/modules-) {
+ warn "WARNING: base directory does not match ..../lib/modules\n";
+}
+
+# Find the list of .o files living under $basedir
+#if ($verbose) { printf "Locating all modules\n"; }
+my($ofile) = "";
+my($file) = "";
+my(@liblist) = ();
+find sub {
+ if ( -f $_ && ! -d $_ ) {
+ $file = $File::Find::name;
+ if ( $file =~ /.o$/ ) {
+ push(@liblist, $file);
+ if ($verbose) { printf "$file\n"; }
+ }
+ }
+}, $basedir;
+if ($verbose) { printf "Finished locating modules\n"; }
+
+foreach $obj ( @liblist, $kernel ){
+ # turn the input file name into a target tag name
+ # vmlinux is a special that is only used to resolve symbols
+ if($obj =~ /vmlinux/) {
+ $tgtname = "vmlinux";
+ } else {
+ ($tgtname) = $obj =~ m-(/lib/modules/.*)$-;
+ }
+
+ warn "MODULE = $tgtname\n" if $verbose;
+
+ # get a list of symbols
+ @output=`nm $obj`;
+ $ksymtab=grep m/ __ksymtab/, @output;
+
+ # gather the exported symbols
+ if($ksymtab){
+ # explicitly exported
+ foreach ( @output ) {
+ / __ksymtab_(.*)$/ and do {
+ warn "sym = $1\n" if $verbose;
+ $exp->{$1} = $tgtname;
+ };
+ }
+ } else {
+ # exporting all symbols
+ foreach ( @output) {
+ / [ABCDGRST] (.*)$/ and do {
+ warn "syma = $1\n" if $verbose;
+ $exp->{$1} = $tgtname;
+ };
+ }
+ }
+ # gather the unresolved symbols
+ foreach ( @output ) {
+ !/ __this_module/ && / U (.*)$/ and do {
+ warn "und = $1\n" if $verbose;
+ push @{$dep->{$tgtname}}, $1;
+ };
+ }
+}
+
+
+# reduce dependancies: remove unresolvable and resolved from vmlinux
+# remove duplicates
+foreach $module (keys %$dep) {
+ $mod->{$module} = {};
+ foreach (@{$dep->{$module}}) {
+ if( $exp->{$_} ) {
+ warn "resolved symbol $_ in file $exp->{$_}\n" if $verbose;
+ next if $exp->{$_} =~ /vmlinux/;
+ $mod->{$module}{$exp->{$_}} = 1;
+ } else {
+ warn "unresolved symbol $_ in file $module\n";
+ }
+ }
+}
+
+# resolve the dependancies for each module
+if ($stdout == 1) {
+ foreach $module ( keys %$mod ) {
+ print "$module:\t";
+ @sorted = sort bydep keys %{$mod->{$module}};
+ print join(" \\\n\t",@sorted);
+ print "\n\n";
+ }
+} else {
+ open(OFILE, ">$basedir/modules.dep");
+ foreach $module ( keys %$mod ) {
+ print OFILE "$module:\t";
+ @sorted = sort bydep keys %{$mod->{$module}};
+ print OFILE join(" \\\n\t",@sorted);
+ print OFILE "\n\n";
+ }
+}
+
+
+sub bydep
+{
+ foreach my $f ( keys %{$mod->{$b}} ) {
+ if($f eq $a) {
+ return 1;
+ }
+ }
+ return -1;
+}
+
+
+
+__END__
+
+=head1 NAME
+
+depmod.pl - a cross platform script to generate kernel module dependency
+ lists which can then be used by modprobe.
+
+=head1 SYNOPSIS
+
+depmod.pl [OPTION]... [basedir]...
+
+Example:
+
+ depmod.pl -F linux/System.map target/lib/modules
+
+=head1 DESCRIPTION
+
+The purpose of this script is to automagically generate a list of of kernel
+module dependancies. This script produces dependancy lists that should be
+identical to the depmod program from the modutils package. Unlike the depmod
+binary, however, depmod.pl is designed to be run on your host system, not
+on your target system.
+
+This script was written by David Schleef <ds@schleef.org> to be used in
+conjunction with the BusyBox modprobe applet.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-h --help>
+
+This displays the help message.
+
+=item B<-b --basedir>
+
+The base directory uner which the target's modules will be found. This
+defaults to the /lib/modules directory.
+
+=item B<-k --kernel>
+
+Kernel binary for the target. You must either supply a kernel binary
+or a kernel symbol file (using the -F option).
+
+=item B<-F --kernelsyms>
+
+Kernel symbol file for the target. You must supply either a kernel symbol file
+kernel binary for the target (using the -k option).
+
+=item B<-n --stdout>
+
+Write to stdout instead of modules.dep. This is currently hard coded...
+kernel binary for the target (using the -k option).
+
+=item B<--verbose>
+
+Be verbose (not implemented)
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (c) 2001 David Schleef <ds@schleef.org>
+Copyright (c) 2001 Erik Andersen <andersen@lineo.com>
+Copyright (c) 2001 Stuart Hughes <stuarth@lineo.com>
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=head1 AUTHOR
+
+David Schleef <ds@schleef.org>
+
+=cut
+
+# $Id: depmod.pl,v 1.1.3.1 2004/12/29 07:07:44 honor Exp $
+
diff --git a/release/src/router/busybox/examples/inittab b/release/src/router/busybox/examples/inittab
new file mode 100755
index 00000000..38df9249
--- /dev/null
+++ b/release/src/router/busybox/examples/inittab
@@ -0,0 +1,90 @@
+# /etc/inittab init(8) configuration for BusyBox
+#
+# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
+#
+#
+# Note, BusyBox init doesn't support runlevels. The runlevels field is
+# completely ignored by BusyBox init. If you want runlevels, use sysvinit.
+#
+#
+# Format for each entry: <id>:<runlevels>:<action>:<process>
+#
+# <id>: WARNING: This field has a non-traditional meaning for BusyBox init!
+#
+# The id field is used by BusyBox init to specify the controlling tty for
+# the specified process to run on. The contents of this field are
+# appended to "/dev/" and used as-is. There is no need for this field to
+# be unique, although if it isn't you may have strange results. If this
+# field is left blank, it is completely ignored. Also note that if
+# BusyBox detects that a serial console is in use, then all entries
+# containing non-empty id fields will _not_ be run. BusyBox init does
+# nothing with utmp. We don't need no stinkin' utmp.
+#
+# <runlevels>: The runlevels field is completely ignored.
+#
+# <action>: Valid actions include: sysinit, respawn, askfirst, wait, once,
+# restart, ctrlaltdel, and shutdown.
+#
+# Note: askfirst acts just like respawn, but before running the specified
+# process it displays the line "Please press Enter to activate this
+# console." and then waits for the user to press enter before starting
+# the specified process.
+#
+# Note: unrecognised actions (like initdefault) will cause init to emit
+# an error message, and then go along with its business.
+#
+# <process>: Specifies the process to be executed and it's command line.
+#
+# Note: BusyBox init works just fine without an inittab. If no inittab is
+# found, it has the following default behavior:
+# ::sysinit:/etc/init.d/rcS
+# ::askfirst:/bin/sh
+# ::ctrlaltdel:/sbin/reboot
+# ::shutdown:/sbin/swapoff -a
+# ::shutdown:/bin/umount -a -r
+# ::restart:/sbin/init
+#
+# if it detects that /dev/console is _not_ a serial console, it will
+# also run:
+# tty2::askfirst:/bin/sh
+# tty3::askfirst:/bin/sh
+# tty4::askfirst:/bin/sh
+#
+# Boot-time system configuration/initialization script.
+# This is run first except when booting in single-user mode.
+#
+::sysinit:/etc/init.d/rcS
+
+# /bin/sh invocations on selected ttys
+#
+# Note below that we prefix the shell commands with a "-" to indicate to the
+# shell that it is supposed to be a login shell. Normally this is handled by
+# login, but since we are bypassing login in this case, BusyBox lets you do
+# this yourself...
+#
+# Start an "askfirst" shell on the console (whatever that may be)
+::askfirst:-/bin/sh
+# Start an "askfirst" shell on /dev/tty2-4
+tty2::askfirst:-/bin/sh
+tty3::askfirst:-/bin/sh
+tty4::askfirst:-/bin/sh
+
+# /sbin/getty invocations for selected ttys
+tty4::respawn:/sbin/getty 38400 tty5
+tty5::respawn:/sbin/getty 38400 tty6
+
+# Example of how to put a getty on a serial line (for a terminal)
+#::respawn:/sbin/getty -L ttyS0 9600 vt100
+#::respawn:/sbin/getty -L ttyS1 9600 vt100
+#
+# Example how to put a getty on a modem line.
+#::respawn:/sbin/getty 57600 ttyS2
+
+# Stuff to do when restarting the init process
+::restart:/sbin/init
+
+# Stuff to do before rebooting
+::ctrlaltdel:/sbin/reboot
+::shutdown:/bin/umount -a -r
+::shutdown:/sbin/swapoff -a
+
diff --git a/release/src/router/busybox/examples/mk2knr.pl b/release/src/router/busybox/examples/mk2knr.pl
new file mode 100755
index 00000000..1259b843
--- /dev/null
+++ b/release/src/router/busybox/examples/mk2knr.pl
@@ -0,0 +1,84 @@
+#!/usr/bin/perl -w
+#
+# @(#) mk2knr.pl - generates a perl script that converts lexemes to K&R-style
+#
+# How to use this script:
+# - In the busybox directory type 'examples/mk2knr.pl files-to-convert'
+# - Review the 'convertme.pl' script generated and remove / edit any of the
+# substitutions in there (please especially check for false positives)
+# - Type './convertme.pl same-files-as-before'
+# - Compile and see if it works
+#
+# BUGS: This script does not ignore strings inside comments or strings inside
+# quotes (it probably should).
+
+# set this to something else if you want
+$convertme = 'convertme.pl';
+
+# internal-use variables (don't touch)
+$convert = 0;
+%converted = ();
+
+# if no files were specified, print usage
+die "usage: $0 file.c | file.h\n" if scalar(@ARGV) == 0;
+
+# prepare the "convert me" file
+open(CM, ">$convertme") or die "convertme.pl $!";
+print CM "#!/usr/bin/perl -p -i\n\n";
+
+# process each file passed on the cmd line
+while (<>) {
+
+ # if the line says "getopt" in it anywhere, we don't want to muck with it
+ # because option lists tend to include strings like "cxtzvOf:" which get
+ # matched by the "check for mixed case" regexps below
+ next if /getopt/;
+
+ # tokenize the string into just the variables
+ while (/([a-zA-Z_][a-zA-Z0-9_]*)/g) {
+ $var = $1;
+
+ # ignore the word "BusyBox"
+ next if ($var =~ /BusyBox/);
+
+ # this checks for javaStyle or szHungarianNotation
+ $convert++ if ($var =~ /^[a-z]+[A-Z][a-z]+/);
+
+ # this checks for PascalStyle
+ $convert++ if ($var =~ /^[A-Z][a-z]+[A-Z][a-z]+/);
+
+ # if we want to add more checks, we can add 'em here, but the above
+ # checks catch "just enough" and not too much, so prolly not.
+
+ if ($convert) {
+ $convert = 0;
+
+ # skip ahead if we've already dealt with this one
+ next if ($converted{$var});
+
+ # record that we've dealt with this var
+ $converted{$var} = 1;
+
+ print CM "s/\\b$var\\b/"; # more to come in just a minute
+
+ # change the first letter to lower-case
+ $var = lcfirst($var);
+
+ # put underscores before all remaining upper-case letters
+ $var =~ s/([A-Z])/_$1/g;
+
+ # now change the remaining characters to lower-case
+ $var = lc($var);
+
+ print CM "$var/g;\n";
+ }
+ }
+}
+
+# tidy up and make the $convertme script executable
+close(CM);
+chmod 0755, $convertme;
+
+# print a helpful help message
+print "Done. Scheduled name changes are in $convertme.\n";
+print "Please review/modify it and then type ./$convertme to do the search & replace.\n";
diff --git a/release/src/router/busybox/examples/udhcp/sample.bound b/release/src/router/busybox/examples/udhcp/sample.bound
new file mode 100755
index 00000000..20035267
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/sample.bound
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Sample udhcpc renew script
+
+RESOLV_CONF="/etc/udhcpc/resolv.conf"
+
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+if [ -n "$router" ]
+then
+ echo "deleting routers"
+ while /sbin/route del default gw 0.0.0.0 dev $interface
+ do :
+ done
+
+ for i in $router
+ do
+ /sbin/route add default gw $i dev $interface
+ done
+fi
+
+echo -n > $RESOLV_CONF
+[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
+for i in $dns
+do
+ echo adding dns $i
+ echo nameserver $i >> $RESOLV_CONF
+done \ No newline at end of file
diff --git a/release/src/router/busybox/examples/udhcp/sample.deconfig b/release/src/router/busybox/examples/udhcp/sample.deconfig
new file mode 100755
index 00000000..b221bcf1
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/sample.deconfig
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Sample udhcpc deconfig script
+
+/sbin/ifconfig $interface 0.0.0.0
diff --git a/release/src/router/busybox/examples/udhcp/sample.nak b/release/src/router/busybox/examples/udhcp/sample.nak
new file mode 100755
index 00000000..f4d08e66
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/sample.nak
@@ -0,0 +1,4 @@
+#!/bin/sh
+# Sample udhcpc nak script
+
+echo Received a NAK: $message
diff --git a/release/src/router/busybox/examples/udhcp/sample.renew b/release/src/router/busybox/examples/udhcp/sample.renew
new file mode 100755
index 00000000..c953e975
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/sample.renew
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Sample udhcpc bound script
+
+RESOLV_CONF="/etc/udhcpc/resolv.conf"
+
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+if [ -n "$router" ]
+then
+ echo "deleting routers"
+ while /sbin/route del default gw 0.0.0.0 dev $interface
+ do :
+ done
+
+ for i in $router
+ do
+ /sbin/route add default gw $i dev $interface
+ done
+fi
+
+echo -n > $RESOLV_CONF
+[ -n "$domain" ] && echo domain $domain >> $RESOLV_CONF
+for i in $dns
+do
+ echo adding dns $i
+ echo nameserver $i >> $RESOLV_CONF
+done \ No newline at end of file
diff --git a/release/src/router/busybox/examples/udhcp/sample.script b/release/src/router/busybox/examples/udhcp/sample.script
new file mode 100755
index 00000000..9b717ac3
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/sample.script
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Currently, we only dispatch according to command. However, a more
+# elaborate system might dispatch by command and interface or do some
+# common initialization first, especially if more dhcp event notifications
+# are added.
+
+exec /usr/share/udhcpc/sample.$1
diff --git a/release/src/router/busybox/examples/udhcp/simple.script b/release/src/router/busybox/examples/udhcp/simple.script
new file mode 100755
index 00000000..a52a7f81
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/simple.script
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# udhcpc script edited by Tim Riker <Tim@Rikers.org>
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF="/etc/resolv.conf"
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+ deconfig)
+ /sbin/ifconfig $interface 0.0.0.0
+ ;;
+
+ renew|bound)
+ /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+ if [ -n "$router" ] ; then
+ echo "deleting routers"
+ while route del default gw 0.0.0.0 dev $interface ; do
+ :
+ done
+
+ for i in $router ; do
+ route add default gw $i dev $interface
+ done
+ fi
+
+ echo -n > $RESOLV_CONF
+ [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
+ for i in $dns ; do
+ echo adding dns $i
+ echo nameserver $i >> $RESOLV_CONF
+ done
+ ;;
+esac
+
+exit 0
diff --git a/release/src/router/busybox/examples/udhcp/udhcpd.conf b/release/src/router/busybox/examples/udhcp/udhcpd.conf
new file mode 100755
index 00000000..2b93e0fa
--- /dev/null
+++ b/release/src/router/busybox/examples/udhcp/udhcpd.conf
@@ -0,0 +1,116 @@
+# Sample udhcpd configuration file (/etc/udhcpd.conf)
+
+# The start and end of the IP lease block
+
+start 192.168.0.20 #default: 192.168.0.20
+end 192.168.0.254 #default: 192.168.0.254
+
+
+# The interface that udhcpd will use
+
+interface eth0 #default: eth0
+
+
+# The maximim number of leases (includes addressesd reserved
+# by OFFER's, DECLINE's, and ARP conficts
+
+#max_leases 254 #default: 254
+
+
+# If remaining is true (default), udhcpd will store the time
+# remaining for each lease in the udhcpd leases file. This is
+# for embedded systems that cannot keep time between reboots.
+# If you set remaining to no, the absolute time that the lease
+# expires at will be stored in the dhcpd.leases file.
+
+#remaining yes #default: yes
+
+
+# The time period at which udhcpd will write out a dhcpd.leases
+# file. If this is 0, udhcpd will never automatically write a
+# lease file. (specified in seconds)
+
+#auto_time 7200 #default: 7200 (2 hours)
+
+
+# The amount of time that an IP will be reserved (leased) for if a
+# DHCP decline message is received (seconds).
+
+#decline_time 3600 #default: 3600 (1 hour)
+
+
+# The amount of time that an IP will be reserved (leased) for if an
+# ARP conflct occurs. (seconds
+
+#conflict_time 3600 #default: 3600 (1 hour)
+
+
+# How long an offered address is reserved (leased) in seconds
+
+#offer_time 60 #default: 60 (1 minute)
+
+# If a lease to be given is below this value, the full lease time is
+# instead used (seconds).
+
+#min_lease 60 #defult: 60
+
+
+# The location of the leases file
+
+#lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases
+
+# The location of the pid file
+#pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid
+
+# Everytime udhcpd writes a leases file, the below script will be called.
+# Useful for writing the lease file to flash every few hours.
+
+#notify_file #default: (no script)
+
+#notify_file dumpleases # <--- usefull for debugging
+
+# The following are bootp specific options, setable by udhcpd.
+
+#siaddr 192.168.0.22 #default: 0.0.0.0
+
+#sname zorak #default: (none)
+
+#boot_file /var/nfs_root #default: (none)
+
+# The remainer of options are DHCP options and can be specifed with the
+# keyword 'opt' or 'option'. If an option can take multiple items, such
+# as the dns option, they can be listed on the same line, or multiple
+# lines. The only option with a default is 'lease'.
+
+#Examles
+opt dns 192.168.10.2 192.168.10.10
+option subnet 255.255.255.0
+opt router 192.168.10.2
+opt wins 192.168.10.10
+option dns 129.219.13.81 # appened to above DNS servers for a total of 3
+option domain local
+option lease 864000 # 10 days of seconds
+
+
+# Currently supported options, for more info, see options.c
+#opt subnet
+#opt timezone
+#opt router
+#opt timesvr
+#opt namesvr
+#opt dns
+#opt logsvr
+#opt cookiesvr
+#opt lprsvr
+#opt bootsize
+#opt domain
+#opt swapsvr
+#opt rootpath
+#opt ipttl
+#opt mtu
+#opt broadcast
+#opt wins
+#opt lease
+#opt ntpsrv
+#opt tftp
+#opt bootfile
diff --git a/release/src/router/busybox/examples/undeb b/release/src/router/busybox/examples/undeb
new file mode 100755
index 00000000..a72e1e2b
--- /dev/null
+++ b/release/src/router/busybox/examples/undeb
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# This should work with the GNU version of tar and gzip!
+# This should work with the bash or ash shell!
+# Requires the programs (ar, tar, gzip, and the pager more or less).
+#
+usage() {
+echo "Usage: undeb -c package.deb <Print control file info>"
+echo " undeb -l package.deb <List contents of deb package>"
+echo " undeb -x package.deb /foo/boo <Extract deb package to this directory,"
+echo " put . for current directory>"
+exit
+}
+
+deb=$2
+
+exist() {
+if [ "$deb" = "" ]; then
+usage
+elif [ ! -s "$deb" ]; then
+echo "Can't find $deb!"
+exit
+fi
+}
+
+if [ "$1" = "" ]; then
+usage
+elif [ "$1" = "-l" ]; then
+exist
+type more >/dev/null 2>&1 && pager=more
+type less >/dev/null 2>&1 && pager=less
+[ "$pager" = "" ] && echo "No pager found!" && exit
+(ar -p $deb control.tar.gz | tar -xzO *control ; echo -e "\nPress enter to scroll, q to Quit!\n" ; ar -p $deb data.tar.gz | tar -tzv) | $pager
+exit
+elif [ "$1" = "-c" ]; then
+exist
+ar -p $deb control.tar.gz | tar -xzO *control
+exit
+elif [ "$1" = "-x" ]; then
+exist
+if [ "$3" = "" ]; then
+usage
+elif [ ! -d "$3" ]; then
+echo "No such directory $3!"
+exit
+fi
+ar -p $deb data.tar.gz | tar -xzvpf - -C $3 || exit
+echo
+echo "Extracted $deb to $3!"
+exit
+else
+usage
+fi
diff --git a/release/src/router/busybox/examples/unrpm b/release/src/router/busybox/examples/unrpm
new file mode 100755
index 00000000..376286a6
--- /dev/null
+++ b/release/src/router/busybox/examples/unrpm
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# This should work with the GNU version of cpio and gzip!
+# This should work with the bash or ash shell!
+# Requires the programs (cpio, gzip, and the pager more or less).
+#
+usage() {
+echo "Usage: unrpm -l package.rpm <List contents of rpm package>"
+echo " unrpm -x package.rpm /foo/boo <Extract rpm package to this directory,"
+echo " put . for current directory>"
+exit
+}
+
+rpm=$2
+
+exist() {
+if [ "$rpm" = "" ]; then
+usage
+elif [ ! -s "$rpm" ]; then
+echo "Can't find $rpm!"
+exit
+fi
+}
+
+if [ "$1" = "" ]; then
+usage
+elif [ "$1" = "-l" ]; then
+exist
+type more >/dev/null 2>&1 && pager=more
+type less >/dev/null 2>&1 && pager=less
+[ "$pager" = "" ] && echo "No pager found!" && exit
+(echo -e "\nPress enter to scroll, q to Quit!\n" ; rpm2cpio $rpm | cpio -tv --quiet) | $pager
+exit
+elif [ "$1" = "-x" ]; then
+exist
+if [ "$3" = "" ]; then
+usage
+elif [ ! -d "$3" ]; then
+echo "No such directory $3!"
+exit
+fi
+rpm2cpio $rpm | (umask 0 ; cd $3 ; cpio -idmuv) || exit
+echo
+echo "Extracted $rpm to $3!"
+exit
+else
+usage
+fi