This commit was manufactured by cvs2svn to create branch 'rtems-4-6-branch'.

Cherrypick from master 2003-08-06 19:20:52 UTC Jennifer Averett <Jennifer.Averett@OARcorp.com> '2003-08-06	Thomas Doerfler<Thomas.Doerfler@imd-systems.de>':
    c/src/tests/samples/fileio/Makefile.am
    c/src/tests/samples/fileio/fileio.doc
    c/src/tests/samples/fileio/init.c
    c/src/tests/samples/fileio/system.h
    cpukit/libmisc/fsmount/Makefile.am
    cpukit/libmisc/fsmount/README
    cpukit/libmisc/fsmount/fsmount.c
    cpukit/libmisc/fsmount/fsmount.h
Cherrypick from master 2003-06-18 15:15:48 UTC Ralf Corsepius <ralf.corsepius@rtems.org> '2003-06-18	Ralf Corsepius <corsepiu@faw.uni-ulm.de>':
    bootstrap
    config.sub
This commit is contained in:
cvs2git
2003-08-06 19:20:53 +00:00
parent e8f496809f
commit a97ee41919
10 changed files with 2854 additions and 0 deletions

193
bootstrap Executable file
View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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();
}

View File

@@ -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 */

1504
config.sub vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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.

View File

@@ -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;
}

View File

@@ -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 */