[PATCH 06/12] NFS: Remove support for cexp
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed Apr 11 14:07:32 UTC 2018
Avoid use of RTEMS_RELLDFLAGS.
---
cpukit/libfs/src/nfsclient/Makefile.am | 55 +---
cpukit/libfs/src/nfsclient/src/cexphelp.c | 27 --
cpukit/libfs/src/nfsclient/src/dirutils.c | 385 -------------------------
cpukit/libfs/src/nfsclient/src/nfs.c | 4 +-
cpukit/libfs/src/nfsclient/src/nfs.modini.c | 38 ---
cpukit/libfs/src/nfsclient/src/nfsTest.c | 386 --------------------------
cpukit/libfs/src/nfsclient/src/rpcio.modini.c | 26 --
7 files changed, 9 insertions(+), 912 deletions(-)
delete mode 100644 cpukit/libfs/src/nfsclient/src/cexphelp.c
delete mode 100644 cpukit/libfs/src/nfsclient/src/dirutils.c
delete mode 100644 cpukit/libfs/src/nfsclient/src/nfs.modini.c
delete mode 100644 cpukit/libfs/src/nfsclient/src/nfsTest.c
delete mode 100644 cpukit/libfs/src/nfsclient/src/rpcio.modini.c
diff --git a/cpukit/libfs/src/nfsclient/Makefile.am b/cpukit/libfs/src/nfsclient/Makefile.am
index 04d840f507..db539b95ba 100644
--- a/cpukit/libfs/src/nfsclient/Makefile.am
+++ b/cpukit/libfs/src/nfsclient/Makefile.am
@@ -1,55 +1,14 @@
include $(top_srcdir)/automake/compile.am
-#%dirutils.obj: %dirutils.o
-# $(LD) -r -o $@ $^
-project_lib_PROGRAMS = dirutils.rel
-dirutils_rel_SOURCES = src/dirutils.c
-dirutils_rel_CPPFLAGS = $(AM_CPPFLAGS)
-dirutils_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
-
if LIBNETWORKING
project_lib_LIBRARIES = libnfs.a
-
-$(PROJECT_LIB)/libnfs.a: libnfs.a
- $(INSTALL_DATA) $< $(PROJECT_LIB)/libnfs.a
-TMPINSTALL_FILES = $(PROJECT_LIB)/libnfs.a
-
-
-# if you have CEXP set this variable to 'YES'
-# and some "help" info will be compiled in.
-libnfs_a_SOURCES = src/rpcio.c src/rpcio.h
-libnfs_a_SOURCES += src/nfs.c src/sock_mbuf.c src/xdr_mbuf.c
-libnfs_a_SOURCES += proto/mount_prot.h proto/nfs_prot.h
-
-# With CEXP
-# libnfs_a_SOURCES += dirutils.c rpcio.modini.c nfs.modini.c cexphelp.c
-
-# PGMS=${ARCH}/nfs.obj ${ARCH}/rpcio.obj ${ARCH}/dirutils.obj
-
-libnfs_a_CPPFLAGS = $(AM_CPPFLAGS)
-libnfs_a_CPPFLAGS += -I$(srcdir)/proto
-libnfs_a_CPPFLAGS += -UHAVE_CEXP
-
-#%nfs.obj: %nfs.o %nfs.modini.o
-# $(LD) -r -o $@ $^ -L../proto/$(ARCH) -lnfsprot
-project_lib_PROGRAMS += nfs.rel
-nfs_rel_SOURCES = src/nfs.c proto/nfs_prot.h proto/mount_prot.h
-nfs_rel_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/proto
-nfs_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
-nfs_rel_LDADD = libnfs.a
-
-#%rpcio.obj: %rpcio.o %sock_mbuf.o %xdr_mbuf.o %rpcio.modini.o
-# $(LD) -r -o $@ $^
-project_lib_PROGRAMS += rpcio.rel
-rpcio_rel_SOURCES = src/rpcio.c src/sock_mbuf.c src/xdr_mbuf.c
-rpcio_rel_CPPFLAGS = $(AM_CPPFLAGS)
-rpcio_rel_LDFLAGS = $(RTEMS_RELLDFLAGS)
-
-libnfs_a_SOURCES += proto/nfs_prot_xdr.c proto/nfs_prot.h
-libnfs_a_SOURCES += proto/mount_prot_xdr.c proto/mount_prot.h
-
-libnfs_a_CPPFLAGS += -I$(srcdir)/proto
-libnfs_a_CPPFLAGS += -UHAVE_CEXP
+libnfs_a_SOURCES =
+libnfs_a_SOURCES += proto/mount_prot_xdr.c
+libnfs_a_SOURCES += proto/nfs_prot_xdr.c
+libnfs_a_SOURCES += src/nfs.c
+libnfs_a_SOURCES += src/rpcio.c
+libnfs_a_SOURCES += src/sock_mbuf.c
+libnfs_a_SOURCES += src/xdr_mbuf.c
endif
diff --git a/cpukit/libfs/src/nfsclient/src/cexphelp.c b/cpukit/libfs/src/nfsclient/src/cexphelp.c
deleted file mode 100644
index 09c73774f6..0000000000
--- a/cpukit/libfs/src/nfsclient/src/cexphelp.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * @file
- *
- * @brief CEXP Help Information
- * @ingroup libfs
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <librtemsNfs.h>
-#include <cexpHelp.h>
-CEXP_HELP_TAB_BEGIN(rtemsNfs)
- HELP(
-"Mount a remote filesystem (NFS). The mount point (must not be a NFS dir)\n"
-"is created on the fly if not existing already.\n"
-"uid/gid to use may be specified:\n"
-" hostspec: [uid.gid@]hostname_or_ipaddr\n"
- , int, nfsMount, (char *hostspec, char *exportdir, char *mntpoint)
- ),
- HELP(
-"Print all currently mounted NFS directories to open file handle.\n"
-"Pass f = 0 to print to stdout\n"
- , int, nfsMountsShow, (FILE *f)
- ),
-CEXP_HELP_TAB_END
diff --git a/cpukit/libfs/src/nfsclient/src/dirutils.c b/cpukit/libfs/src/nfsclient/src/dirutils.c
deleted file mode 100644
index 7155ef998a..0000000000
--- a/cpukit/libfs/src/nfsclient/src/dirutils.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/**
- * @file
- *
- * @brief Basic NFS Filesystem Utilities for Testing the NFS
- * @ingroup libfs
- */
-
-/*
- * Author: Till Straumann, <strauman at slac.stanford.edu>, 10/2002
- *
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- * Till Straumann <strauman at slac.stanford.edu>, 2002-2007,
- * Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- * the Stanford Linear Accelerator Center, Stanford University,
- * under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software. Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef __vxworks
-#include <vxWorks.h>
-#endif
-#include <stdio.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <limits.h> /* PATH_MAX */
-
-#include <inttypes.h> /* PRI* */
-#include <rtems/inttypes.h> /* extended PRI* */
-
-#ifdef HAVE_CEXP
-#include <cexpHelp.h>
-#endif
-
-#ifndef __vxworks
-/*
- * Prototypes to avoid warnings
- */
-int pwd(void);
-int ls(char *dir, char *opts);
-int cp(char *from, char *to, char *opts);
-int ln(char *to, char *name, char *opts);
-int rm(char *path);
-int cd(char *path);
-#endif
-
-#ifndef __vxworks
-int
-pwd(void)
-{
-char buf[PATH_MAX];
-
- if ( !getcwd(buf,PATH_MAX)) {
- perror("getcwd");
- return -1;
- } else {
- printf("%s\n",buf);
- }
- return 0;
-}
-
-static int
-ls_r(char *path, char *chpt, char *name, struct stat *buf)
-{
-char *t;
- sprintf(chpt, "/%s", name);
- if (lstat(path,buf)) {
- fprintf(stderr,"stat(%s): %s\n", path, strerror(errno));
- return -1;
- }
- switch ( buf->st_mode & S_IFMT ) {
- case S_IFSOCK:
- case S_IFIFO: t = "|"; break;
-
- default:
- case S_IFREG:
- case S_IFBLK:
- case S_IFCHR:
- t = ""; break;
- case S_IFDIR:
- t = "/"; break;
- case S_IFLNK:
- t = "@"; break;
- }
-
- printf("%10li, %10" PRIooff_t "b, %5i.%-5i 0%04" PRIomode_t " %s%s\n",
- buf->st_ino,
- buf->st_size,
- buf->st_uid,
- buf->st_gid,
- buf->st_mode & ~S_IFMT,
- name,
- t);
- *chpt = 0;
- return 0;
-}
-
-int
-ls(char *dir, char *opts)
-{
-struct dirent *de;
-char path[PATH_MAX+1];
-char *chpt;
-DIR *dp = 0;
-int rval = -1;
-struct stat buf;
-
- if ( !dir )
- dir = ".";
-
- strncpy(path, dir, PATH_MAX);
- path[PATH_MAX] = 0;
- chpt = path+strlen(path);
-
- if ( !(dp=opendir(dir)) ) {
- perror("opendir");
- goto cleanup;
- }
-
- while ( (de = readdir(dp)) ) {
- ls_r(path, chpt, de->d_name, &buf);
- }
-
- rval = 0;
-
-cleanup:
- if (dp)
- closedir(dp);
- return rval;
-}
-#endif
-
-#if 0
- fprintf(stderr, "usage: cp(""from"",[""to""[,""-f""]]\n");
- fprintf(stderr, " ""to""==NULL -> stdout\n");
- fprintf(stderr, " ""-f"" -> overwrite existing file\n");
-#endif
-
-int
-cp(char *from, char *to, char *opts)
-{
-struct stat st;
-int rval = -1;
-int fd = -1;
-FILE *fst = 0;
-FILE *tst = 0;
-int flags = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
-
- if (from) {
-
- if ((fd=open(from,O_RDONLY,0)) < 0) {
- fprintf(stderr,
- "Opening %s for reading: %s\n",
- from,
- strerror(errno));
- goto cleanup;
- }
-
- if (fstat(fd, &st)) {
- fprintf(stderr,
- "rstat(%s): %s\n",
- from,
- strerror(errno));
- goto cleanup;
- }
-
-
- if (!S_ISREG(st.st_mode)) {
- fprintf(stderr,"Refuse to copy a non-regular file\n");
- errno = EINVAL;
- goto cleanup;
- }
- /* Now create a stream -- I experienced occasional weirdness
- * when circumventing the streams attached to fildno(stdin)
- * by reading/writing to the underlying fd's directly ->
- * for now we always go through buffered I/O...
- */
- if ( !(fst=fdopen(fd,"r")) ) {
- fprintf(stderr,
- "Opening input stream [fdopen()] failed: %s\n",
- strerror(errno));
- goto cleanup;
- }
- /* at this point, we have a stream and don't need 'fd' anymore */
- fd = -1;
-
- } else {
- fst = stdin;
- st.st_mode = 0644;
- }
-
- if (opts && strchr(opts,'f'))
- flags &= ~ O_EXCL;
-
- if (to) {
- if ( (fd=open(to,flags,st.st_mode)) < 0 ) {
- fprintf(stderr,
- "Opening %s for writing: %s\n",
- to,
- strerror(errno));
- goto cleanup;
- }
- if ( !(tst=fdopen(fd, "w")) ) {
- fprintf(stderr,
- "Opening output stream [fdopen()] failed: %s\n",
- strerror(errno));
- goto cleanup;
- }
- /* at this point we have a stream and don't need 'fd' anymore */
- fd = -1;
- } else {
- tst = stdout;
- }
-
- /* clear old errors */
- clearerr(fst);
- clearerr(tst);
-
- /* use macro versions on register vars; stdio is already buffered,
- * there's nothing to be gained by reading/writing blocks into
- * a secondary buffer...
- */
- {
- register int ch;
- register FILE *f = fst;
- register FILE *t = tst;
- while ( EOF != (ch = getc(f)) && EOF != putc(ch, t) )
- /* nothing else */;
- }
-
- if ( ferror(fst) ) {
- fprintf(stderr,"Read error: %s\n",strerror(errno));
- goto cleanup;
- }
- if ( ferror(tst) ) {
- fprintf(stderr,"Write error: %s\n",strerror(errno));
- goto cleanup;
- }
-
- rval = 0;
-
-cleanup:
-
- if ( fd >= 0 )
- close(fd);
-
- if ( fst ) {
- if ( from )
- fclose(fst);
- else
- clearerr(fst);
- }
- if ( tst ) {
- if ( to )
- fclose(tst);
- else {
- /* flush stdout */
- fflush(tst);
- clearerr(tst);
- }
- }
-
- return rval;
-}
-
-int
-ln(char *to, char *name, char *opts)
-{
- if (!to) {
- fprintf(stderr,"ln: need 'to' argument\n");
- return -1;
- }
- if (!name) {
- if ( !(name = strrchr(to,'/')) ) {
- fprintf(stderr,
- "ln: 'unable to link %s to %s\n",
- to,to);
- return -1;
- }
- name++;
- }
- if (opts && strchr(opts,'s')) {
- if (symlink(name,to)) {
- fprintf(stderr,"symlink: %s\n",strerror(errno));
- return -1;
- }
- } else {
- if (link(name,to)) {
- fprintf(stderr,"hardlink: %s\n",strerror(errno));
- return -1;
- }
- }
- return 0;
-}
-
-int
-rm(char *path)
-{
- return unlink(path);
-}
-
-int
-cd(char *path)
-{
- return chdir(path);
-}
-
-#ifdef HAVE_CEXP
-static CexpHelpTabRec _cexpHelpTabDirutils[] RTEMS_UNUSED = {
- HELP(
-"copy a file: cp(""from"",[""to""[,""-f""]])\n\
- from = NULL <-- stdin\n\
- to = NULL --> stdout\n\
- option -f: overwrite existing file\n",
- int,
- cp, (char *from, char *to, char *options)
- ),
- HELP(
-"list a directory: ls([""dir""])\n",
- int,
- ls, (char *dir)
- ),
- HELP(
-"remove a file\n",
- int,
- rm, (char *path)
- ),
- HELP(
-"change the working directory\n",
- int,
- cd, (char *path)
- ),
- HELP(
-"create a link: ln(""to"",""name"",""[-s]""\n\
- -s creates a symlink\n",
- int,
- ln, (char *to, char *name, char *options)
- ),
- HELP("",,0,)
-};
-#endif
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c
index f4f53191b5..b8427f1387 100644
--- a/cpukit/libfs/src/nfsclient/src/nfs.c
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c
@@ -80,8 +80,8 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <nfs_prot.h>
-#include <mount_prot.h>
+#include "../proto/nfs_prot.h"
+#include "../proto/mount_prot.h"
#include "rpcio.h"
#include "librtemsNfs.h"
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.modini.c b/cpukit/libfs/src/nfsclient/src/nfs.modini.c
deleted file mode 100644
index 57adf23aa1..0000000000
--- a/cpukit/libfs/src/nfsclient/src/nfs.modini.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * @file
- *
- * @brief NFS Module Initialize
- * @ingroup libfs
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "librtemsNfs.h"
-
-/* CEXP dynamic loader support */
-
-void
-_cexpModuleInitialize(void *mod)
-{
-#if defined(DEBUG)
- /* print load address (in case we crash while initializing) */
-unsigned lr;
- __asm__ __volatile__(
- " bl thisis_loaded_at \n"
- "thisis_loaded_at: \n"
- " mflr %0 \n"
- : "=r"(lr) ::"lr");
- printf("thisis_loaded_at: 0x%08x\n",lr);
-#endif
- nfsInit(0,0);
-}
-
-int
-_cexpModuleFinalize(void *mod)
-{
- return nfsCleanup();
-}
-
-
diff --git a/cpukit/libfs/src/nfsclient/src/nfsTest.c b/cpukit/libfs/src/nfsclient/src/nfsTest.c
deleted file mode 100644
index 5b6951af58..0000000000
--- a/cpukit/libfs/src/nfsclient/src/nfsTest.c
+++ /dev/null
@@ -1,386 +0,0 @@
-/**
- * @file
- *
- * @brief Test Program for Evaluating NFS Read Throughput
- * @ingroup libfs
- *
- * This test code allows for evaluating NFS read performance
- * under various scenarios:
- * - synchronous reads with various buffer sizes (select
- * 'num_readers' == 0, see below).
- * - pseudo 'read-ahead' using multiple threads that issue
- * NFS reads from the same file (but from different offsets)
- * in parallel.
- * Rationale: each NFS read request is synchronous, i.e., the
- * caller sends a request to the server and waits for the
- * reply to come back. Performance enhancement can be expected
- * by requesting multiple blocks in parallel rather than
- * sequentially.
- *
- * rtems_interval
- * nfsTestRead(char *file_name, int chunk_size, int num_readers);
- *
- * 1) creates 'num_readers' threads, each opening 'file_name' for
- * reading on a separate file descriptor.
- * 2) creates message queues for communicating with reader threads
- *
- * 3) read file using nfsTestReadBigbuf() until EOF is reached
- *
- * 4) releases resources.
- *
- * RETURNS: Time elapsed during step 3 in ms. This is measured
- * using the system clock so make sure the test file
- * is big enough.
- *
- * nfsTestReadBigbuf() synchronously reads a block of
- * 'num_readers * chunk_size' (which may be bigger than
- * the UDP limit of 8k) using 'num_reader' threads to
- * retrieve the various pieces of the big block in parallel.
- * This speeds up things since several RPC calls can
- * be in the works at once.
- *
- * NOTES:
- * - if 'num_readers' == 0 this corresponds to an 'ordinary'
- * NFS read. 'num_readers' == 1 schedules a single reader
- * thread (== ordinary NFS read + message passing overhead).
- * - no actual processing on the data is done; they are simply
- * thrown away. A real, performance-critical application could
- * pipeline 'reader' and 'cruncher' threads.
- * - read is not completely asynchronous; synchronization is still
- * performed at 'big block' boundaries (num_readers * chunk_size).
- */
-
-
-
-
-/*
- * Author: Till Straumann <strauman at slac.stanford.edu>, 2006
- *
- * Authorship
- * ----------
- * This software (NFS-2 client implementation for RTEMS) was created by
- * Till Straumann <strauman at slac.stanford.edu>, 2002-2007,
- * Stanford Linear Accelerator Center, Stanford University.
- *
- * Acknowledgement of sponsorship
- * ------------------------------
- * The NFS-2 client implementation for RTEMS was produced by
- * the Stanford Linear Accelerator Center, Stanford University,
- * under Contract DE-AC03-76SFO0515 with the Department of Energy.
- *
- * Government disclaimer of liability
- * ----------------------------------
- * Neither the United States nor the United States Department of Energy,
- * nor any of their employees, makes any warranty, express or implied, or
- * assumes any legal liability or responsibility for the accuracy,
- * completeness, or usefulness of any data, apparatus, product, or process
- * disclosed, or represents that its use would not infringe privately owned
- * rights.
- *
- * Stanford disclaimer of liability
- * --------------------------------
- * Stanford University makes no representations or warranties, express or
- * implied, nor assumes any liability for the use of this software.
- *
- * Stanford disclaimer of copyright
- * --------------------------------
- * Stanford University, owner of the copyright, hereby disclaims its
- * copyright and all other rights in this software. Hence, anyone may
- * freely use it for any purpose without restriction.
- *
- * Maintenance of notices
- * ----------------------
- * In the interest of clarity regarding the origin and status of this
- * SLAC software, this and all the preceding Stanford University notices
- * are to remain affixed to any copy or derivative of this software made
- * or distributed by the recipient and are to be affixed to any copy of
- * software made or distributed by the recipient that contains a copy or
- * derivative of this software.
- *
- * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
- */
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems.h>
-#include <rtems/error.h>
-
-#include <fcntl.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-unsigned nfsTestReaderPri = 80;
-
-struct nfsTestReq_ {
- unsigned offset; /* file offset */
- int size; /* IN: block size to read (must be < 8192), OUT: bytes actually read */
- void *buf; /* data buffer address */
-};
-
-/* Queue for sending requests to parallel reader tasks */
-rtems_id nfsTestRQ = 0;
-/* Queue to pickup replies from parallel reader tasks */
-rtems_id nfsTestAQ = 0;
-
-
-/* Reader task; opens its own file descriptor
- * and works on requests:
- * - obtain request from request queue.
- * - lseek to the requested file offset
- * - NFS read into buffer
- * - queue reply.
- *
- * Note that this implementation is very simple
- * - no full error checking.
- * - file is opened/closed by thread
- * it's main purpose is running quick tests.
- */
-static rtems_task
-nfsTestReader(rtems_task_argument arg)
-{
-int fd = open((char*)arg,O_RDONLY);
-unsigned long s;
-struct nfsTestReq_ r;
-rtems_status_code sc;
-
- if ( fd < 0 ) {
- perror("nfsReader: opening file");
- goto cleanup;
- }
- do {
- s = sizeof(r);
- sc = rtems_message_queue_receive(nfsTestRQ, &r, &s, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
- if ( RTEMS_SUCCESSFUL != sc ) {
- rtems_error(sc, "(Error) reading from message queue");
- goto cleanup;
- }
- if ( !r.buf ) {
- /* They send a NULL buffer as a shutdown request */
- break;
- }
-#ifdef DEBUG
- printf("Reader: reading offset %u, size %i to %p ... ",
- r.offset, r.size, r.buf);
-#endif
- /* seek to requested offset */
- lseek(fd, r.offset, SEEK_SET);
- r.size = read(fd, r.buf, r.size);
-#ifdef DEBUG
- printf("got %i\n",r.size);
-#endif
- rtems_message_queue_send(nfsTestAQ, &r, sizeof(r));
- } while (1) ;
-
-cleanup:
- if ( fd >= 0 )
- close(fd);
- rtems_task_delete(RTEMS_SELF);
-}
-
-
-/* helper to create and start a reader task */
-static rtems_id
-taskSpawn(char *filenm, int inst)
-{
-rtems_status_code sc;
-rtems_id tid;
-
- sc = rtems_task_create(
- rtems_build_name('n','t','t','0'+inst),
- nfsTestReaderPri,
- 1400,
- RTEMS_DEFAULT_MODES,
- RTEMS_DEFAULT_ATTRIBUTES,
- &tid);
- if ( RTEMS_SUCCESSFUL != sc ) {
- rtems_error(sc,"(Error) Creating nfs reader task %i",inst);
- return 0;
- }
-
- sc = rtems_task_start(tid, nfsTestReader, (rtems_task_argument)filenm);
- if ( RTEMS_SUCCESSFUL != sc ) {
- rtems_error(sc,"(Error) Staritng nfs reader task %i",inst);
- rtems_task_delete(tid);
- return 0;
- }
-
- return tid;
-}
-
-/*
- * Read nrd*sz bytes into 'buf' from file offset 'off'
- * using 'nrd' parallel reader tasks to do the job.
- * This helper routine schedules 'nrd' requests to
- * the reader tasks and waits for all requests to
- * finish.
- *
- * RETURNS: number of bytes read or -1 (error).
- *
- * CAVEATS:
- * - assumes read requests always return 'sz' bytes
- * unless the end of file is reached.
- * THIS ASSUMPTION SHOULD NOT BE MADE WHEN WRITING
- * ANY 'REAL' CODE.
- */
-static int
-nfsTestReadBigbuf(char *buf, int off, int sz, int nrd)
-{
-int i,rval=0;
-struct nfsTestReq_ r;
- r.buf = buf;
- r.size = sz;
- r.offset = off;
- /* send out parallel requests */
- for (i=0; i<nrd; i++) {
- rtems_message_queue_send(nfsTestRQ, &r, sizeof(r));
- r.offset += sz;
- r.buf += sz;
- }
- /* wait for answers */
- for (i=0; i<nrd; i++) {
- unsigned long s = sizeof(r);
- rtems_message_queue_receive(nfsTestAQ, &r, &s, RTEMS_WAIT, RTEMS_NO_TIMEOUT);
- if ( r.size < 0 ) {
- fprintf(stderr,"A reader failed\n");
- rval = -1;
- } else {
- /* FIXME sanity checks:
- * - catch case where any-but-last read returns < sz
- */
- if ( rval >= 0 ) {
- rval += r.size;
- }
- }
- }
- return rval;
-}
-
-/* Main test routine
- *
- * Read file 'fname' usint 'nrd' parallel reader tasks,
- * each operating on chunks of 'sz' bytes.
- *
- * RETURNS: time elapsed in milliseconds. This is measured
- * using the system clock. Hence, for the result
- * to be meaningful, the file must be big enough.
- *
- */
-rtems_interval
-nfsTestRead(char *fnam, int sz, int nrd)
-{
-int i;
-unsigned off;
-rtems_interval now=-1, then, tickspsec;
-rtems_status_code sc;
-int fd=-1;
-char *buf=0;
-
- if ( nrd < 0 )
- nrd = 0;
-
- if ( sz < 0 || sz > 8192 ) {
- fprintf(stderr,"\n");
- return -1;
- }
-
- nfsTestRQ = nfsTestAQ = 0;
-
- /* Allocate buffer */
- if ( ! (buf=malloc(sz*(nrd ? nrd : 1))) ) {
- perror("allocating buffer");
- goto cleanup;
- }
-
- /* Don't bother proceeding if we can't open the file for reading */
- if ( (fd=open(fnam,O_RDONLY)) < 0 ) {
- perror("opening file");
- goto cleanup;
- }
- if ( nrd ) {
- close(fd); fd = -1;
- }
-
- /* Create request queue */
- if ( nrd ) {
- sc = rtems_message_queue_create(
- rtems_build_name('n','t','r','q'),
- nrd,
- sizeof(struct nfsTestReq_),
- RTEMS_DEFAULT_ATTRIBUTES,
- & nfsTestRQ );
-
- if ( RTEMS_SUCCESSFUL != sc ) {
- rtems_error(sc, "(Error) creating request queue");
- nfsTestRQ = 0;
- goto cleanup;
- }
-
- /* Spawn reader tasks */
- for ( i=0; i<nrd; i++ ) {
- if ( ! taskSpawn(fnam, i) )
- goto cleanup;
- }
-
- /* Create reply queue */
- sc = rtems_message_queue_create(
- rtems_build_name('n','t','a','q'),
- nrd,
- sizeof(struct nfsTestReq_),
- RTEMS_DEFAULT_ATTRIBUTES,
- & nfsTestAQ );
-
- if ( RTEMS_SUCCESSFUL != sc ) {
- rtems_error(sc, "(Error) creating reply queue");
- nfsTestAQ = 0;
- goto cleanup;
- }
- }
-
- /* Timed main loop */
- then = rtems_clock_get_ticks_since_boot();
-
- if ( nrd ) {
- off = 0;
- while ((i = nfsTestReadBigbuf(buf, off, sz, nrd)) > 0 ) {
-#ifdef DEBUG
- printf("bigbuf got %i\n", i);
-#endif
- off += i;
- }
- } else {
- while ( (i = read(fd, buf, sz)) > 0 )
- /* nothing else to do */;
- if ( i < 0 ) {
- perror("reading");
- goto cleanup;
- }
- }
-
- now = rtems_clock_get_ticks_since_boot();
- now = (now-then)*1000;
- ticksspec = rtems_clock_get_ticks_per_second();
- now /= tickspsec; /* time in ms */
-
-cleanup:
- if ( fd >= 0 )
- close(fd);
-
- if ( nfsTestRQ ) {
- /* request tasks to shutdown by sending NULL buf request */
- struct nfsTestReq_ r;
- r.buf = 0;
- for ( i=0; i<nrd; i++ ) {
- rtems_message_queue_send( nfsTestRQ, &r, sizeof(r) );
- }
- /* cheat: instead of proper synchronization with shutdown we simply
- * delay for a second...
- */
- rtems_task_wake_after( tickspsec );
- rtems_message_queue_delete( nfsTestRQ );
- }
- if ( nfsTestAQ )
- rtems_message_queue_delete( nfsTestAQ );
- free(buf);
- return now;
-}
diff --git a/cpukit/libfs/src/nfsclient/src/rpcio.modini.c b/cpukit/libfs/src/nfsclient/src/rpcio.modini.c
deleted file mode 100644
index f0359974de..0000000000
--- a/cpukit/libfs/src/nfsclient/src/rpcio.modini.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * @file
- *
- * @brief RPCIO Module Initialize
- * @ingroup libfs
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "librtemsNfs.h"
-/* CEXP module support (magic init) */
-void
-_cexpModuleInitialize(void *mod)
-{
- rpcUdpInit();
-}
-
-int
-_cexpModuleFinalize(void *mod)
-{
- return rpcUdpCleanup();
-}
-
-
--
2.12.3
More information about the devel
mailing list