summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap193
-rw-r--r--c/src/tests/samples/fileio/Makefile.am42
-rw-r--r--c/src/tests/samples/fileio/fileio.doc45
-rw-r--r--c/src/tests/samples/fileio/init.c600
-rw-r--r--c/src/tests/samples/fileio/system.h136
-rwxr-xr-xconfig.sub1504
-rw-r--r--cpukit/libmisc/fsmount/Makefile.am43
-rw-r--r--cpukit/libmisc/fsmount/README24
-rw-r--r--cpukit/libmisc/fsmount/fsmount.c196
-rw-r--r--cpukit/libmisc/fsmount/fsmount.h71
10 files changed, 2854 insertions, 0 deletions
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000000..3060d85dec
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,193 @@
+#! /bin/sh
+#
+# helps bootstrapping, when checked out from CVS
+# requires GNU autoconf and GNU automake
+#
+# $Id$
+
+# this is not meant to be exported outside the source tree
+
+# NOTE: Inspired by libtool's autogen script
+
+# to be run from the toplevel directory of RTEMS'
+# source tree
+
+progname=`basename $0`
+top_srcdir=`dirname $0`
+
+verbose="";
+quiet="false"
+mode="generate"
+
+usage()
+{
+ echo
+ echo "usage: ${progname} [-h|-q|-v]"
+ echo
+ echo "options:"
+ echo " -h .. display this message and exit";
+ echo " -q .. quiet, don't display directories";
+ echo " -v .. verbose, pass -v to automake when invoking automake"
+ echo " -c .. clean, remove all aclocal/autoconf/automake generated files"
+ echo
+ exit 1;
+}
+
+generate_bspdir_acinclude()
+{
+cat << EOF > acinclude.m4~
+# RTEMS_CHECK_BSPDIR(RTEMS_BSP)
+AC_DEFUN([RTEMS_CHECK_BSPDIR],
+[
+ RTEMS_BSP_ALIAS(ifelse([\$1],,[\${RTEMS_BSP}],[\$1]),bspdir)
+ case "\$bspdir" in
+EOF
+
+for i in */bsp_specs; do
+ d=`dirname $i`
+cat << EOF >> acinclude.m4~
+ $d )
+ AC_CONFIG_SUBDIRS([$d]);;
+EOF
+done
+cat << EOF >> acinclude.m4~
+ *)
+ AC_MSG_ERROR([Invalid BSP]);;
+ esac
+])
+EOF
+if cmp -s acinclude.m4 acinclude.m4~ 2>/dev/null; then
+ echo "acinclude.m4 is unchanged";
+else
+ cp acinclude.m4~ acinclude.m4
+fi
+rm -f acinclude.m4~
+}
+
+if test ! -f $top_srcdir/aclocal/version.m4; then
+ echo "${progname}:"
+ echo " Installation problem: Can't find file aclocal/version.m4"
+ exit 1;
+fi
+
+while test $# -gt 0; do
+case $1 in
+-h|--he|--hel|--help)
+ usage ;;
+-q|--qu|--qui|--quie|--quiet)
+ quiet="true";
+ shift;;
+-v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
+ verbose="-v";
+ shift;;
+-c|--cl|--cle|--clea|--clean)
+ mode="clean";
+ shift;;
+-*) echo "unknown option $1" ;
+ usage ;;
+*) echo "invalid parameter $1" ;
+ usage ;;
+esac
+done
+
+case $mode in
+generate)
+ AUTOCONF=${AUTOCONF-autoconf}
+ if test -z "$AUTOCONF"; then
+ echo "You must have autoconf installed to run $program"
+ exit 1
+ fi
+
+ AUTOHEADER=${AUTOHEADER-autoheader}
+ if test -z "$AUTOHEADER"; then
+ echo "You must have autoconf installed to run $program"
+ exit 1
+ fi
+
+ AUTOMAKE=${AUTOMAKE-automake}
+ if test -z "$AUTOMAKE"; then
+ echo "You must have automake installed to run $program"
+ exit 1
+ fi
+
+ ACLOCAL=${ACLOCAL-aclocal}
+ if test -z "$ACLOCAL"; then
+ echo "You must have automake installed to run $program"
+ exit 1
+ fi
+
+ case $top_srcdir in
+ /* ) aclocal_dir=$top_srcdir
+ ;;
+ *) aclocal_dir=`pwd`/$top_srcdir
+ ;;
+ esac
+
+ confs=`find . \( -name 'configure.in' -o -name 'configure.ac' \) -print`
+ for i in $confs; do
+ dir=`dirname $i`;
+ configure=`basename $i`;
+ ( test "$quiet" = "true" || echo "$dir";
+ cd $dir;
+ test -n "`grep RTEMS_CHECK_BSPDIR ${configure}`" && \
+ generate_bspdir_acinclude;
+ pat="s,\$(RTEMS_TOPdir),${aclocal_dir},g"
+ aclocal_args=`grep '^[ ]*ACLOCAL_AMFLAGS' Makefile.am | \
+ sed -e 's%.*ACLOCAL_AMFLAGS.*\=[ ]*%%g' -e $pat ` ;
+ test "$verbose" = "-v" && echo "${ACLOCAL} $aclocal_args"
+ ${ACLOCAL} $aclocal_args;
+ test -n "`grep CONFIG_HEADER ${configure}`" && ${AUTOHEADER} \
+ && test "$verbose" = "-v" && echo "${AUTOHEADER}";
+ test -n "`grep RTEMS_BSP_CONFIGURE ${configure}`" && ${AUTOHEADER} \
+ && test "$verbose" = "-v" && echo "${AUTOHEADER}";
+ test -f Makefile.am && ${AUTOMAKE} -a -c $verbose ;
+ ${AUTOCONF};
+ test -f Makefile.am && test -n "`grep 'stamp-h\.in' Makefile.in`" \
+ && echo timestamp > stamp-h.in
+ )
+ done
+ ;;
+
+clean)
+ test "$quiet" = "true" || echo "removing automake generated Makefile.in files"
+ files=`find . -name 'Makefile.am' -print | sed -e 's%\.am%\.in%g'` ;
+ for i in $files; do if test -f $i; then
+ rm -f $i
+ test "$verbose" = "-v" && echo "$i"
+ fi; done
+
+ test "$quiet" = "true" || echo "removing configure files"
+ files=`find . -name 'configure' -print` ;
+ test "$verbose" = "-v" && test -n "$files" && echo "$files" ;
+ for i in $files; do if test -f $i; then
+ # The config.sub shipped with automake <= 1.7.5 does handle c4x/tic4x-* correctly.
+ # rm -f config.sub
+ rm -f $i config.guess depcomp install-sh mdate-sh missing \
+ mkinstalldirs texinfo.tex
+ test "$verbose" = "-v" && echo "$i"
+ fi; done
+
+ test "$quiet" = "true" || echo "removing aclocal.m4 files"
+ files=`find . -name 'aclocal.m4' -print` ;
+ test "$verbose" = "-v" && test -n "$files" && echo "$files" ;
+ for i in $files; do if test -f $i; then
+ rm -f $i
+ test "$verbose" = "-v" && echo "$i"
+ fi; done
+
+ find . -name '*~' -print | xargs rm -f
+ find . -name 'bspopts.h*' -print | xargs rm -f
+ find . -name '*.orig' -print | xargs rm -f
+ find . -name '*.rej' -print | xargs rm -f
+ find . -name 'config.status' -print | xargs rm -f
+ find . -name 'config.log' -print | xargs rm -f
+ find . -name 'config.cache' -print | xargs rm -f
+ find . -name 'Makefile' -print | xargs rm -f
+ find . -name '.deps' -print | xargs rm -rf
+ find . -name '.libs' -print | xargs rm -rf
+ find . -name 'stamp-h.in' | xargs rm -rf
+ find . -name 'autom4te*.cache' | xargs rm -rf
+ ;;
+esac
+
+exit 0
diff --git a/c/src/tests/samples/fileio/Makefile.am b/c/src/tests/samples/fileio/Makefile.am
new file mode 100644
index 0000000000..4ea7b3a71d
--- /dev/null
+++ b/c/src/tests/samples/fileio/Makefile.am
@@ -0,0 +1,42 @@
+##
+## Makefile.am,v 1.9 2002/08/11 05:18:59 ralf Exp
+##
+
+
+SAMPLE = fileio
+PGM = ${ARCH}/$(SAMPLE).exe
+
+MANAGERS = io message semaphore
+
+C_FILES = init.c
+C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT))
+
+H_FILES = system.h
+noinst_HEADERS = $(H_FILES)
+
+DOCTYPES = doc scn
+DOCS = $(DOCTYPES:%=$(SAMPLE).%)
+
+SRCS = $(DOCS) $(C_FILES) $(H_FILES)
+OBJS = $(C_O_FILES)
+
+PRINT_SRCS = $(DOCS)
+
+include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
+include $(top_srcdir)/../../../../automake/compile.am
+include $(top_srcdir)/../../../../automake/leaf.am
+include $(top_srcdir)/sample.am
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+all-local: ${ARCH} $(TMPINSTALL_FILES)
+
+${PGM}: $(OBJS) $(LINK_FILES)
+ $(make-exe)
+
+EXTRA_DIST = $(C_FILES) $(DOCS)
+
+include $(top_srcdir)/../../../../automake/local.am
+
diff --git a/c/src/tests/samples/fileio/fileio.doc b/c/src/tests/samples/fileio/fileio.doc
new file mode 100644
index 0000000000..30438f710d
--- /dev/null
+++ b/c/src/tests/samples/fileio/fileio.doc
@@ -0,0 +1,45 @@
+#
+# fileio.doc,v
+#
+# COPYRIGHT (c) 1989-1999.
+# On-Line Applications Research Corporation (OAR).
+#
+# The license and distribution terms for this file may be
+# found in the file LICENSE in this distribution or at
+# http://www.OARcorp.com/rtems/license.html.
+#
+
+This sample implements some basic tests for the file systems
+available. It provides the following functionality:
+
+- perform basic file read/write tests on arbitrary file paths with
+selectable I/O buffer size
+- perform functions to evaluate FAT disk partition tables
+- perform functions to mount FAT disks to the file system tree
+
+A sample session might look like this:
+
+- start this system
+
+- select "p" (part_table_initialize) to read in the partition table of
+first harddisk, enter the device name "/dev/hda", when prompted
+
+- select "f" (fsmount) to try to mount the partitions
+ /dev/hda1../dev/hdc4 to corresponding mount points. Non-existant
+ partitions will report an error, but will not abort the tests
+
+- select "w" (write file) to create a new file on the mounted disk (or
+ in the IMFS). Enter the file name (e.g. "/mnt/hda1/test_1M.txt"),
+ the file size (e.g. 64K or 2M) and the buffer size to use for the
+ write calls (e.g. 32 or 4K). Then the sample will try to write the
+ corresponding file and print the time consumed and data rate achived.
+
+- select "r" (read file) to read a file (without displaying the
+ contents). It has similar parameters as "write file", but does not
+ query the file size.
+
+- select "s" to call the rtems shell with its various capabilities.
+
+
+
+
diff --git a/c/src/tests/samples/fileio/init.c b/c/src/tests/samples/fileio/init.c
new file mode 100644
index 0000000000..965a54dbd7
--- /dev/null
+++ b/c/src/tests/samples/fileio/init.c
@@ -0,0 +1,600 @@
+/* Init
+ *
+ * This routine is the initialization task for this test program.
+ * It is called from init_exec and has the responsibility for creating
+ * and starting the tasks that make up the test. If the time of day
+ * clock is required for the test, it should also be set to a known
+ * value by this function.
+ *
+ * Input parameters: NONE
+ *
+ * Output parameters: NONE
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * init.c,v 1.11 2000/06/12 15:00:12 joel Exp
+ */
+
+#define CONFIGURE_INIT
+#include "system.h"
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <rtems.h>
+#include <fcntl.h>
+#include <rtems/error.h>
+#include <dosfs.h>
+#include <ctype.h>
+#include <rtems/ide_part_table.h>
+#include <rtems/libcsupport.h>
+#include <rtems/fsmount.h>
+
+/*
+ * Table of FAT file systems that will be mounted
+ * with the "fsmount" function.
+ * See cpukit/libmisc/fsmount for definition of fields
+ */
+fstab_t fs_table[] = {
+ {
+ "/dev/hda1","/mnt/hda1",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hda2","/mnt/hda2",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hda3","/mnt/hda3",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hda4","/mnt/hda4",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hdc1","/mnt/hdc1",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hdc2","/mnt/hdc2",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hdc3","/mnt/hdc3",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ },
+ {
+ "/dev/hdc4","/mnt/hdc4",
+ &msdos_ops, RTEMS_FILESYSTEM_READ_WRITE,
+ FSMOUNT_MNT_OK | FSMOUNT_MNTPNT_CRTERR | FSMOUNT_MNT_FAILED,
+ 0
+ }
+};
+
+#ifndef MIN
+#define MIN(a,b) (((a) > (b)) ? (b) : (a))
+#endif
+
+#define USE_SHELL
+
+#ifdef USE_SHELL
+#include <rtems/shell.h>
+
+void fileio_start_shell(void)
+{
+ printf(" =========================\n");
+ printf(" starting shell\n");
+ printf(" =========================\n");
+ shell_init("SHLL",0,100,"/dev/console",
+ B9600 | CS8,
+ 0);
+ rtems_task_suspend(RTEMS_SELF);
+}
+
+#endif /* USE_SHELL */
+
+void fileio_print_free_heap(void)
+{
+ printf("--- unused dynamic memory: %lu bytes ---\n",
+ (unsigned long) malloc_free_space());
+}
+
+
+void fileio_part_table_initialize(void)
+{
+ char devname[64];
+ rtems_status_code rc;
+
+ printf(" =========================\n");
+ printf(" Initialize partition table\n");
+ printf(" =========================\n");
+ fileio_print_free_heap();
+ printf(" Enter device to initialize ==>");
+ fgets(devname,sizeof(devname)-1,stdin);
+ while (devname[strlen(devname)-1] == '\n') {
+ devname[strlen(devname)-1] = '\0';
+ }
+ /*
+ * call function
+ */
+ rc = rtems_ide_part_table_initialize(devname);
+ printf("result = %d\n",rc);
+ fileio_print_free_heap();
+}
+
+void fileio_fsmount(void)
+{
+ rtems_status_code rc;
+
+ printf(" =========================\n");
+ printf(" Process fsmount table\n");
+ printf(" =========================\n");
+ fileio_print_free_heap();
+ /*
+ * call function
+ */
+ rc = rtems_fsmount( fs_table,
+ sizeof(fs_table)/sizeof(fs_table[0]),
+ NULL);
+ printf("result = %d\n",rc);
+ fileio_print_free_heap();
+}
+
+void fileio_list_file(void)
+{
+ char fname[1024];
+ char *buf_ptr = NULL;
+ unsigned32 flen = 0;
+ int fd = -1;
+ ssize_t n;
+ size_t buf_size = 100;
+
+ rtems_interval start_tick,curr_tick,ticks_per_sec;
+
+ printf(" =========================\n");
+ printf(" LIST FILE ... \n");
+ printf(" =========================\n");
+ fileio_print_free_heap();
+ printf(" Enter filename to list ==>");
+ fgets(fname,sizeof(fname)-1,stdin);
+ while (fname[strlen(fname)-1] == '\n') {
+ fname[strlen(fname)-1] = '\0';
+ }
+ /*
+ * allocate buffer of given size
+ */
+ if (buf_size > 0) {
+ buf_ptr = malloc(buf_size);
+ }
+
+ if (buf_ptr != NULL) {
+ printf("\n Trying to open file \"%s\" for read\n",fname);
+ fd = open(fname,O_RDONLY);
+ if (fd < 0) {
+ printf("*** file open failed, errno = %d(%s)\n",errno,strerror(errno));
+ }
+ }
+
+ if (fd >= 0) {
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick);
+ do {
+ n = read(fd,buf_ptr,buf_size);
+ if (n > 0) {
+ write(1,buf_ptr,n);
+ flen += n;
+ }
+ } while (n > 0);
+
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick);
+
+ printf("\n ******** End of file reached, flen = %d\n",flen);
+ close(fd);
+
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec);
+ printf("time elapsed for read: %g seconds\n",
+ ((double)curr_tick-start_tick)/ticks_per_sec);
+ }
+ /*
+ * free buffer
+ */
+ if (buf_ptr != NULL) {
+ free(buf_ptr);
+ }
+ fileio_print_free_heap();
+}
+
+/*
+ * convert a size string (like 34K or 12M) to actual byte count
+ */
+boolean fileio_str2size(const char *str,unsigned32 *res_ptr)
+{
+ boolean failed = FALSE;
+ unsigned long size;
+ char suffix = ' ';
+
+ if (1 > sscanf(str,"%lu%c",&size,&suffix)) {
+ failed = TRUE;
+ }
+ else if (toupper(suffix) == 'K') {
+ size *= 1024;
+ }
+ else if (toupper(suffix) == 'M') {
+ size *= 1024UL*1024UL;
+ }
+ else if (isalpha(suffix)) {
+ failed = TRUE;
+ }
+
+ if (!failed) {
+ *res_ptr = size;
+ }
+ return failed;
+}
+
+void fileio_write_file(void)
+{
+ char fname[1024];
+ char tmp_str[32];
+ unsigned32 file_size = 0;
+ unsigned32 buf_size = 0;
+ size_t curr_pos,bytes_to_copy;
+ int fd = -1;
+ ssize_t n;
+ rtems_interval start_tick,curr_tick,ticks_per_sec;
+ char *bufptr = NULL;
+ boolean failed = FALSE;
+ static const char write_test_string[] =
+ "The quick brown fox jumps over the lazy dog\n";
+ static const char write_block_string[] =
+ "\n----- end of write buffer ------\n";
+
+ printf(" =========================\n");
+ printf(" WRITE FILE ... \n");
+ printf(" =========================\n");
+ fileio_print_free_heap();
+ /*
+ * get number of ticks per second
+ */
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec);
+
+ /*
+ * get path to file to write
+ */
+ if (!failed) {
+ printf("Enter path/filename ==>");
+ fgets(fname,sizeof(fname)-1,stdin);
+ while (fname[strlen(fname)-1] == '\n') {
+ fname[strlen(fname)-1] = '\0';
+ }
+ if (0 == strlen(fname)) {
+ printf("*** no filename entered, aborted\n");
+ failed = TRUE;
+ }
+ }
+ /*
+ * get total file size to write
+ */
+ if (!failed) {
+ printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n"
+ "Enter filesize to write ==>");
+ fgets(tmp_str,sizeof(tmp_str)-1,stdin);
+ failed = fileio_str2size(tmp_str,&file_size);
+ if (failed) {
+ printf("*** illegal file size, aborted\n");
+ }
+ }
+ /*
+ * get block size to write
+ */
+ if (!failed) {
+ printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n"
+ "Enter block size to use for write calls ==>");
+ fgets(tmp_str,sizeof(tmp_str)-1,stdin);
+ failed = fileio_str2size(tmp_str,&buf_size);
+ if (failed) {
+ printf("*** illegal block size, aborted\n");
+ }
+ }
+
+ /*
+ * allocate buffer
+ */
+ if (!failed) {
+ printf("... allocating %lu bytes of buffer for write data\n",
+ (unsigned long)buf_size);
+ bufptr = malloc(buf_size+1); /* extra space for terminating NUL char */
+ if (bufptr == NULL) {
+ printf("*** malloc failed, aborted\n");
+ failed = TRUE;
+ }
+ }
+ /*
+ * fill buffer with test pattern
+ */
+ if (!failed) {
+ printf("... filling buffer with write data\n");
+ curr_pos = 0;
+ /*
+ * fill buffer with test string
+ */
+ while (curr_pos < buf_size) {
+ bytes_to_copy = MIN(buf_size-curr_pos,
+ sizeof(write_test_string)-1);
+ memcpy(bufptr+curr_pos,write_test_string,bytes_to_copy);
+ curr_pos += bytes_to_copy;
+ }
+ /*
+ * put "end" mark at end of buffer
+ */
+ bytes_to_copy = sizeof(write_block_string)-1;
+ if (buf_size >= bytes_to_copy) {
+ memcpy(bufptr+buf_size-bytes_to_copy,
+ write_block_string,
+ bytes_to_copy);
+ }
+ }
+ /*
+ * create file
+ */
+ if (!failed) {
+ printf("... creating file \"%s\"\n",fname);
+ fd = open(fname,O_WRONLY | O_CREAT | O_TRUNC,S_IREAD|S_IWRITE);
+ if (fd < 0) {
+ printf("*** file create failed, errno = %d(%s)\n",errno,strerror(errno));
+ failed = TRUE;
+ }
+ }
+ /*
+ * write file
+ */
+ if (!failed) {
+ printf("... writing to file\n");
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick);
+ curr_pos = 0;
+ do {
+ bytes_to_copy = buf_size;
+ do {
+ n = write(fd,
+ bufptr + (buf_size-bytes_to_copy),
+ MIN(bytes_to_copy,file_size-curr_pos));
+ if (n > 0) {
+ bytes_to_copy -= n;
+ curr_pos += n;
+ }
+ } while ((bytes_to_copy > 0) && (n > 0));
+ } while ((file_size > curr_pos) && (n > 0));
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick);
+ if (n < 0) {
+ failed = TRUE;
+ printf("*** file write failed, "
+ "%lu bytes written, "
+ "errno = %d(%s)\n",
+ (unsigned long)curr_pos,errno,strerror(errno));
+ }
+ else {
+ printf("time elapsed for write: %g seconds\n",
+ ((double)curr_tick-start_tick)/ticks_per_sec);
+ printf("write data rate: %g KBytes/second\n",
+ (((double)file_size) / 1024.0 /
+ (((double)curr_tick-start_tick)/ticks_per_sec)));
+ }
+ }
+ if (fd >= 0) {
+ printf("... closing file\n");
+ close(fd);
+ }
+ if (bufptr != NULL) {
+ printf("... deallocating buffer\n");
+ free(bufptr);
+ bufptr = NULL;
+ }
+ printf("\n ******** End of file write\n");
+ fileio_print_free_heap();
+}
+
+void fileio_read_file(void)
+{
+ char fname[1024];
+ char tmp_str[32];
+ unsigned32 buf_size = 0;
+ size_t curr_pos;
+ int fd = -1;
+ ssize_t n;
+ rtems_interval start_tick,curr_tick,ticks_per_sec;
+ char *bufptr = NULL;
+ boolean failed = FALSE;
+
+ printf(" =========================\n");
+ printf(" READ FILE ... \n");
+ printf(" =========================\n");
+ fileio_print_free_heap();
+ /*
+ * get number of ticks per second
+ */
+ rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_sec);
+
+ /*
+ * get path to file to read
+ */
+ if (!failed) {
+ printf("Enter path/filename ==>");
+ fgets(fname,sizeof(fname)-1,stdin);
+ while (fname[strlen(fname)-1] == '\n') {
+ fname[strlen(fname)-1] = '\0';
+ }
+ if (0 == strlen(fname)) {
+ printf("*** no filename entered, aborted\n");
+ failed = TRUE;
+ }
+ }
+ /*
+ * get block size to read
+ */
+ if (!failed) {
+ printf("use suffix K for Kbytes, M for Mbytes or no suffix for bytes:\n"
+ "Enter block size to use for read calls ==>");
+ fgets(tmp_str,sizeof(tmp_str)-1,stdin);
+ failed = fileio_str2size(tmp_str,&buf_size);
+ if (failed) {
+ printf("*** illegal block size, aborted\n");
+ }
+ }
+
+ /*
+ * allocate buffer
+ */
+ if (!failed) {
+ printf("... allocating %lu bytes of buffer for write data\n",
+ (unsigned long)buf_size);
+ bufptr = malloc(buf_size+1); /* extra space for terminating NUL char */
+ if (bufptr == NULL) {
+ printf("*** malloc failed, aborted\n");
+ failed = TRUE;
+ }
+ }
+ /*
+ * open file
+ */
+ if (!failed) {
+ printf("... opening file \"%s\"\n",fname);
+ fd = open(fname,O_RDONLY);
+ if (fd < 0) {
+ printf("*** file open failed, errno = %d(%s)\n",errno,strerror(errno));
+ failed = TRUE;
+ }
+ }
+ /*
+ * read file
+ */
+ if (!failed) {
+ printf("... reading from file\n");
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &start_tick);
+ curr_pos = 0;
+ do {
+ n = read(fd,
+ bufptr,
+ buf_size);
+ if (n > 0) {
+ curr_pos += n;
+ }
+ } while (n > 0);
+ rtems_clock_get (RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &curr_tick);
+ if (n < 0) {
+ failed = TRUE;
+ printf("*** file read failed, "
+ "%lu bytes read, "
+ "errno = %d(%s)\n",
+ (unsigned long)curr_pos,errno,strerror(errno));
+ }
+ else {
+ printf("%lu bytes read\n",
+ (unsigned long)curr_pos);
+ printf("time elapsed for read: %g seconds\n",
+ ((double)curr_tick-start_tick)/ticks_per_sec);
+ printf("read data rate: %g KBytes/second\n",
+ (((double)curr_pos) / 1024.0 /
+ (((double)curr_tick-start_tick)/ticks_per_sec)));
+ }
+ }
+ if (fd >= 0) {
+ printf("... closing file\n");
+ close(fd);
+ }
+ if (bufptr != NULL) {
+ printf("... deallocating buffer\n");
+ free(bufptr);
+ bufptr = NULL;
+ }
+ printf("\n ******** End of file read\n");
+ fileio_print_free_heap();
+
+}
+
+void fileio_menu (void)
+{
+ char inbuf[10];
+
+ /*
+ * Wait for characters from console terminal
+ */
+ for (;;) {
+ printf(" =========================\n");
+ printf(" RTEMS FILE I/O Test Menu \n");
+ printf(" =========================\n");
+ printf(" p -> part_table_initialize\n");
+ printf(" f -> mount all disks in fs_table\n");
+ printf(" l -> list file\n");
+ printf(" r -> read file\n");
+ printf(" w -> write file\n");
+#ifdef USE_SHELL
+ printf(" s -> start shell\n");
+#endif
+ printf(" Enter your selection ==>");
+
+ inbuf[0] = '\0';
+ fgets(inbuf,sizeof(inbuf),stdin);
+ switch (inbuf[0]) {
+ case 'l':
+ fileio_list_file ();
+ break;
+ case 'r':
+ fileio_read_file ();
+ break;
+ case 'w':
+ fileio_write_file ();
+ break;
+ case 'p':
+ fileio_part_table_initialize ();
+ break;
+ case 'f':
+ fileio_fsmount ();
+ break;
+#ifdef USE_SHELL
+ case 's':
+ fileio_start_shell ();
+ break;
+#endif
+ default:
+ printf("Selection `%c` not implemented\n",inbuf[0]);
+ break;
+ }
+
+ }
+ exit (0);
+}
+
+int menu_tid;
+
+/*
+ * RTEMS Startup Task
+ */
+rtems_task
+Init (rtems_task_argument ignored)
+{
+ puts( "\n\n*** FILE I/O SAMPLE AND TEST ***" );
+
+ fileio_menu();
+}
+
+
diff --git a/c/src/tests/samples/fileio/system.h b/c/src/tests/samples/fileio/system.h
new file mode 100644
index 0000000000..0ab03e905f
--- /dev/null
+++ b/c/src/tests/samples/fileio/system.h
@@ -0,0 +1,136 @@
+/* system.h
+ *
+ * This include file contains information that is included in every
+ * function in the test set.
+ *
+ * COPYRIGHT (c) 1989-1999.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.OARcorp.com/rtems/license.html.
+ *
+ * system.h,v 1.13 2000/06/12 15:00:12 joel Exp
+ */
+
+#include <rtems.h>
+
+/* functions */
+
+rtems_task Init(
+ rtems_task_argument argument
+);
+
+/* global variables */
+
+
+/* configuration information */
+
+#include <bsp.h> /* for device driver prototypes */
+#include <libchip/ata.h> /* for ata driver prototype */
+#include <libchip/ide_ctrl.h> /* for general ide driver prototype */
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+
+#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
+
+#ifdef CONFIGURE_INIT
+rtems_driver_address_table Device_drivers[] =
+ {
+ CONSOLE_DRIVER_TABLE_ENTRY
+ ,CLOCK_DRIVER_TABLE_ENTRY
+#ifdef RTEMS_BSP_HAS_IDE_DRIVER
+ ,IDE_CONTROLLER_DRIVER_TABLE_ENTRY
+ /* important: ATA driver must be after ide drivers */
+ ,ATA_DRIVER_TABLE_ENTRY
+#endif
+ };
+
+#include <rtems/bdbuf.h>
+rtems_bdbuf_config rtems_bdbuf_configuration[] = {
+ {512,128,NULL}
+};
+int rtems_bdbuf_configuration_size =( sizeof(rtems_bdbuf_configuration)
+ /sizeof(rtems_bdbuf_configuration[0]));
+#endif
+
+
+/*
+ * XXX: these values are higher than needed...
+ */
+#define CONFIGURE_MAXIMUM_TASKS 20
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 20
+#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 20
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
+
+#include <confdefs.h>
+
+/*
+ * Handy macros and static inline functions
+ */
+
+/*
+ * Macro to hide the ugliness of printing the time.
+ */
+
+#define print_time(_s1, _tb, _s2) \
+ do { \
+ printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \
+ _s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
+ (_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
+ fflush(stdout); \
+ } while ( 0 )
+
+/*
+ * Macro to print an task name that is composed of ASCII characters.
+ *
+ */
+
+#define put_name( _name, _crlf ) \
+ do { \
+ rtems_unsigned32 c0, c1, c2, c3; \
+ \
+ c0 = ((_name) >> 24) & 0xff; \
+ c1 = ((_name) >> 16) & 0xff; \
+ c2 = ((_name) >> 8) & 0xff; \
+ c3 = (_name) & 0xff; \
+ putchar( (char)c0 ); \
+ if ( c1 ) putchar( (char)c1 ); \
+ if ( c2 ) putchar( (char)c2 ); \
+ if ( c3 ) putchar( (char)c3 ); \
+ if ( (_crlf) ) \
+ putchar( '\n' ); \
+ } while (0)
+
+/*
+ * static inline routine to make obtaining ticks per second easier.
+ */
+
+static inline rtems_unsigned32 get_ticks_per_second( void )
+{
+ rtems_interval ticks_per_second;
+ (void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); return ticks_per_second;
+}
+
+
+/*
+ * This allows us to view the "Test_task" instantiations as a set
+ * of numbered tasks by eliminating the number of application
+ * tasks created.
+ *
+ * In reality, this is too complex for the purposes of this
+ * example. It would have been easier to pass a task argument. :)
+ * But it shows how rtems_id's can sometimes be used.
+ */
+
+#define task_number( tid ) \
+ ( rtems_get_index( tid ) - \
+ rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
+
+/* end of include file */
+
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000000..0bdc334317
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1504 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2003-06-17'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k \
+ | m32r | m68000 | m68k | m88k | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | msp430 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* \
+ | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* \
+ | m32r-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | msp430-* \
+ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+ | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nv1)
+ basic_machine=nv1-cray
+ os=-unicosmp
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparc | sparcv9 | sparcv9b)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/cpukit/libmisc/fsmount/Makefile.am b/cpukit/libmisc/fsmount/Makefile.am
new file mode 100644
index 0000000000..12b0f6976b
--- /dev/null
+++ b/cpukit/libmisc/fsmount/Makefile.am
@@ -0,0 +1,43 @@
+##
+## Makefile.am,v 1.9 2002/08/11 05:51:17 ralf Exp
+##
+
+
+include_rtemsdir = $(includedir)/rtems
+
+LIBNAME = libfsmount
+LIB = $(ARCH)/$(LIBNAME).a
+
+C_FILES = fsmount.c
+C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT))
+
+include_rtems_HEADERS = fsmount.h
+
+OBJS = $(C_O_FILES)
+
+include $(top_srcdir)/../automake/compile.am
+include $(top_srcdir)/../automake/lib.am
+
+$(PROJECT_INCLUDE)/rtems:
+ @$(mkinstalldirs) $@
+$(PROJECT_INCLUDE)/rtems/%.h: %.h
+ $(INSTALL_DATA) $< $@
+
+#
+# (OPTIONAL) Add local stuff here using +=
+#
+
+$(LIB): $(OBJS)
+ $(make-library)
+
+PREINSTALL_FILES = $(PROJECT_INCLUDE)/rtems \
+ $(include_rtems_HEADERS:%=$(PROJECT_INCLUDE)/rtems/%)
+
+all-local: $(ARCH) $(PREINSTALL_FILES) $(OBJS) $(LIB)
+
+.PRECIOUS: $(LIB)
+
+EXTRA_DIST = README fsmount.c
+
+include $(top_srcdir)/../automake/local.am
+
diff --git a/cpukit/libmisc/fsmount/README b/cpukit/libmisc/fsmount/README
new file mode 100644
index 0000000000..88bfda62e7
--- /dev/null
+++ b/cpukit/libmisc/fsmount/README
@@ -0,0 +1,24 @@
+#
+#
+# fsmount information
+#
+# Author: Thomas Doerfler 02/07/2003
+#
+# README,v 1.1 1999/07/09 17:23:15 joel Exp
+#
+
+fsmount.c contains the function fsmount. It processes the
+fs table given as an parameter to create the listed mount points
+and mount the corresponding file systems to their mount points.
+See "c/src/tests/samples/fileio" for a sample on how to use this
+function.
+
+The field "report_reasons" specifies, what results of the mount point
+creation/mount operations should print to the console.
+
+The field "abort_reasons" specifies, what results of the mount point
+creation/mount operations should abort the function. Do not set the
+"abort_reasons" bit, unless you want to stop the processing of the
+fsmount table after the first successful mount.
+
+
diff --git a/cpukit/libmisc/fsmount/fsmount.c b/cpukit/libmisc/fsmount/fsmount.c
new file mode 100644
index 0000000000..1d251199c0
--- /dev/null
+++ b/cpukit/libmisc/fsmount/fsmount.c
@@ -0,0 +1,196 @@
+/*===============================================================*\
+| Project: RTEMS fsmount |
++-----------------------------------------------------------------+
+| File: fsmount.c |
++-----------------------------------------------------------------+
+| Copyright (c) 2003 IMD |
+| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler |
+| <Thomas.Doerfler@imd-systems.de> |
+| all rights reserved |
++-----------------------------------------------------------------+
+| this file contains the fsmount functions. These functions |
+| are used to mount a list of filesystems (and create their mount |
+| points before) |
+| |
+| The license and distribution terms for this file may be |
+| found in the file LICENSE in this distribution or at |
+| http://www.OARcorp.com/rtems/license.html. |
+| |
++-----------------------------------------------------------------+
+| date history ID |
+| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
+| 02.07.03 creation doe |
+\*===============================================================*/
+#include <rtems.h>
+#include <rtems/fsmount.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <imfs.h>
+#include <sys/stat.h>
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+int rtems_fsmount_create_mountpoint
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| This function will create the mount point given |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const char *mount_point
+ )
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| 0, if success, -1 and errno if failed |
+\*=========================================================================*/
+{
+ int rc = 0;
+ char *tok_buffer = NULL;
+ char *token = NULL;
+ int token_len;
+ size_t total_len;
+ IMFS_token_types token_type;
+ struct stat file_info;
+ /*
+ * allocate temp memory to rebuild path name
+ */
+ tok_buffer = calloc(strlen(mount_point)+1,sizeof(char));
+ token = tok_buffer;
+ total_len = 0;
+ do {
+ /*
+ * scan through given string, one segment at a time
+ */
+ token_type = IMFS_get_token(mount_point+total_len,token,&token_len);
+ total_len += token_len;
+ strncpy(tok_buffer,mount_point,total_len);
+ tok_buffer[total_len] = '\0';
+
+ if ((token_type != IMFS_NO_MORE_PATH) &&
+ (token_type != IMFS_CURRENT_DIR) &&
+ (token_type != IMFS_INVALID_TOKEN)) {
+ /*
+ * check, whether segment exists
+ */
+ if (0 != stat(tok_buffer,&file_info)) {
+ /*
+ * if not, create directory
+ */
+ rc = mknod(tok_buffer,S_IRWXU | S_IRWXG | S_IRWXO | S_IFDIR,0);
+ }
+ }
+ } while ((rc == 0) &&
+ (token_type != IMFS_NO_MORE_PATH) &&
+ (token_type != IMFS_INVALID_TOKEN));
+
+ /*
+ * return token buffer to heap
+ */
+ if (tok_buffer != NULL) {
+ free(tok_buffer);
+ }
+ return rc;
+}
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+int rtems_fsmount
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| This function will create the mount points listed and mount the file |
+| systems listed in the calling parameters |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const fstab_t *fstab_ptr,
+ int fstab_count,
+ int *fail_idx
+ )
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| 0, if success, -1 and errno if failed |
+\*=========================================================================*/
+{
+ int rc = 0;
+ int tmp_rc;
+ int fstab_idx = 0;
+ rtems_filesystem_mount_table_entry_t *tmp_mt_entry;
+ boolean terminate = FALSE;
+
+ /*
+ * scan through all fstab entries;
+ */
+ while (!terminate &&
+ (fstab_idx < fstab_count)) {
+ tmp_rc = 0;
+ /*
+ * create mount point
+ */
+ if (tmp_rc == 0) {
+ tmp_rc = rtems_fsmount_create_mountpoint(fstab_ptr->mount_point);
+ if (tmp_rc != 0) {
+ if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNTPNT_CRTERR)) {
+ printf("fsmount: creation of mount point \"%s\" failed: %s\n",
+ fstab_ptr->mount_point,
+ strerror(errno));
+ }
+ if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNTPNT_CRTERR)) {
+ terminate = TRUE;
+ rc = tmp_rc;
+ }
+ }
+ }
+ /*
+ * mount device to given mount point
+ */
+ if (tmp_rc == RTEMS_SUCCESSFUL) {
+ tmp_rc = mount(&tmp_mt_entry,
+ fstab_ptr->fs_ops,
+ fstab_ptr->mount_options,
+ fstab_ptr->dev,
+ fstab_ptr->mount_point);
+ if (tmp_rc != RTEMS_SUCCESSFUL) {
+ if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_FAILED)) {
+ printf("fsmount: mounting of \"%s\" to"
+ " \"%s\" failed: %s\n",
+ fstab_ptr->dev,
+ fstab_ptr->mount_point,
+ strerror(errno));
+ }
+ if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_FAILED)) {
+ terminate = TRUE;
+ rc = tmp_rc;
+ }
+ }
+ else {
+ if (0 != (fstab_ptr->report_reasons & FSMOUNT_MNT_OK)) {
+ printf("fsmount: mounting of \"%s\" to"
+ " \"%s\" succeeded\n",
+ fstab_ptr->dev,
+ fstab_ptr->mount_point);
+ }
+ if (0 != (fstab_ptr->abort_reasons & FSMOUNT_MNT_OK)) {
+ terminate = TRUE;
+ }
+ }
+ }
+ /*
+ * proceed to next entry
+ */
+ if (!terminate) {
+ fstab_ptr++;
+ fstab_idx++;
+ }
+ }
+ if (fail_idx != NULL) {
+ *fail_idx = fstab_idx;
+ }
+ return rc;
+}
+
diff --git a/cpukit/libmisc/fsmount/fsmount.h b/cpukit/libmisc/fsmount/fsmount.h
new file mode 100644
index 0000000000..52346d6d88
--- /dev/null
+++ b/cpukit/libmisc/fsmount/fsmount.h
@@ -0,0 +1,71 @@
+/*===============================================================*\
+| Project: RTEMS fsmount |
++-----------------------------------------------------------------+
+| File: fsmount.h |
++-----------------------------------------------------------------+
+| Copyright (c) 2003 IMD |
+| Ingenieurbuero fuer Microcomputertechnik Th. Doerfler |
+| <Thomas.Doerfler@imd-systems.de> |
+| all rights reserved |
++-----------------------------------------------------------------+
+| this file contains the fsmount functions. These functions |
+| are used to mount a list of filesystems (and create their mount |
+| points before) |
+| |
+| The license and distribution terms for this file may be |
+| found in the file LICENSE in this distribution or at |
+| http://www.OARcorp.com/rtems/license.html. |
+| |
++-----------------------------------------------------------------+
+| date history ID |
+| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
+| 02.07.03 creation doe |
+\*===============================================================*/
+#ifndef _FSMOUNT_H
+#define _FSMOUNT_H
+#include <rtems.h>
+#include <rtems/libio.h>
+#include <rtems/libcsupport.h>
+
+/*
+ * bits to define, what errors will cause reporting (via printf) and
+ * abort of mount processing
+ * Use a combination of these bits
+ * for the fields "report_reasons" and "abort_reasons"
+ */
+#define FSMOUNT_MNT_OK 0x0001 /* mounted ok */
+#define FSMOUNT_MNTPNT_CRTERR 0x0002 /* cannot create mount point */
+#define FSMOUNT_MNT_FAILED 0x0004 /* mounting failed */
+
+typedef struct {
+ char *dev;
+ char *mount_point;
+ rtems_filesystem_operations_table *fs_ops;
+ rtems_filesystem_options_t mount_options;
+ unsigned16 report_reasons;
+ unsigned16 abort_reasons;
+} fstab_t;
+
+
+/*=========================================================================*\
+| Function: |
+\*-------------------------------------------------------------------------*/
+int rtems_fsmount
+(
+/*-------------------------------------------------------------------------*\
+| Purpose: |
+| This function will create the mount points listed and mount the file |
+| systems listed in the calling parameters |
++---------------------------------------------------------------------------+
+| Input Parameters: |
+\*-------------------------------------------------------------------------*/
+ const fstab_t *fstab_ptr, /* Ptr to filesystem mount table */
+ int fstab_count, /* number of entries in mount table*/
+ int *fail_idx /* return: index of failed entry */
+ );
+/*-------------------------------------------------------------------------*\
+| Return Value: |
+| 0, if success, -1 and errno if failed |
+\*=========================================================================*/
+
+#endif /* _FSMOUNT_H */