source: network-demos/nfsClientTest/init.c @ 6d031d5

4.11network-demos-4-10-branchnetwork-demos-4-8-branchnetwork-demos-4-9-branch
Last change on this file since 6d031d5 was 6d031d5, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/07 at 19:33:53

2007-07-18 Joel Sherrill <joel.sherrill@…>

  • init.c: Make the NFS server, remote filesystem, and directory to look at configurable.
  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*  Init
2 *
3 *  This routine is the initialization task for this test program.
4 *
5 *  Don't forget to change the IP addresses
6 */
7
8#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
9#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
10#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
11#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS        20
12#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
13
14#define CONFIGURE_MEMORY_OVERHEAD       256
15#define CONFIGURE_MESSAGE_BUFFER_MEMORY 32 * 1024
16#define CONFIGURE_MAXIMUM_SEMAPHORES    40
17#define CONFIGURE_MAXIMUM_TASKS         20
18#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES        20
19
20#define CONFIGURE_MICROSECONDS_PER_TICK 1000
21
22#define CONFIGURE_INIT_TASK_STACK_SIZE  (64*1024)
23#define CONFIGURE_INIT_TASK_PRIORITY    120
24#define CONFIGURE_INIT_TASK_ATTRIBUTES    RTEMS_FLOATING_POINT
25#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
26                                           RTEMS_NO_TIMESLICE | \
27                                           RTEMS_NO_ASR | \
28                                           RTEMS_INTERRUPT_LEVEL(0))
29
30#define CONFIGURE_MAXIMUM_DRIVERS 10
31#define CONFIGURE_INIT
32
33#include <rtems.h>
34#include <librtemsNfs.h>
35
36/* functions */
37
38rtems_task Init(
39  rtems_task_argument argument
40);
41
42/* configuration information */
43
44#include <rtems/confdefs.h>
45#include <bsp.h>
46
47#include <errno.h>
48#include <time.h>
49
50#include <rtems/confdefs.h>
51#include <stdio.h>
52#include <rtems/rtems_bsdnet.h>
53#include <rtems/ftpd.h>
54#include <rtems/untar.h>
55
56     
57#include <rtems/error.h>
58#include <rpc/rpc.h>
59#include <netinet/in.h>
60#include <time.h>
61
62#include <arpa/inet.h>
63#include <sys/socket.h>
64#include "../networkconfig.h"
65
66#include <rtems_webserver.h>
67
68#define ARGUMENT 0
69
70/*
71 *  The tarfile is built automatically externally so we need to account
72 *  for the leading symbol on the names.
73 */
74#if defined(__sh__)
75  #define SYM(_x) _x
76#else
77  #define SYM(_x) _ ## _x
78#endif
79
80extern int SYM(binary_tarfile_start);
81extern int SYM(binary_tarfile_size);
82#define TARFILE_START SYM(binary_tarfile_start)
83#define TARFILE_SIZE SYM(binary_tarfile_size)
84
85rtems_task Init(
86  rtems_task_argument argument
87)
88{
89  rtems_status_code status;
90  int int_status;
91
92  printf("\n\n*** NFS Client TEST ***\n\r" );
93
94  printf( "Free space %d\n", malloc_free_space() );
95  /*
96   * Load filesystem image
97   */
98  printf("=============== Loading filesystem image ===============\n");
99  status = Untar_FromMemory((void *)(&TARFILE_START), (size_t)&TARFILE_SIZE);
100   
101  printf("============== Look at Local Filesystem ==============\n");
102  printf( "PWD: " );
103  pwd();
104 
105  printf( "\n--->ls /\n" );
106  ls("/");
107
108  printf( "\n--->ls /etc\n" );
109  ls("/etc");
110
111  printf("============== Initializing Network ==============\n");
112  rtems_bsdnet_initialize_network ();
113
114  printf("============== Add Route ==============\n");
115  rtems_bsdnet_show_inet_routes ();
116
117  printf("============== Initializing RPC ==============\n");
118  int_status = rpcUdpInit();
119  if ( int_status )
120    printf( "RPC UDP Initialization failed\n" );
121
122  printf("============== Initializing NFS Subsystem ==============\n");
123  nfsInit( 0, 0 );
124
125  printf("============== Mounting Remote Filesystem ==============\n");
126#if 1
127  /* This code uses the NFS mount wrapper function */
128  int_status = nfsMount( RTEMS_NFS_SERVER, RTEMS_NFS_SERVER_PATH, "/mnt" );
129#else
130  /* This section does it more explicitly */
131  mkdir( "/mnt", 0777 );
132  int_status = mount(
133    NULL,                        /* mount_table_entry_pointer */
134    &nfs_fs_ops,                 /* filesystem_operations_table_pointer */
135    RTEMS_FILESYSTEM_READ_WRITE, /* options */
136                                 /* device aka remote filesystem */
137    RTEMS_NFS_SERVER ":" RTEMS_NFS_SERVER_PATH,
138    "/mnt"                       /* mount_point */
139  );
140#endif
141  if ( int_status )
142    printf( "NFS Mount failed -- %s\n", strerror(errno) );
143
144  printf("============== Look at Remote Filesystem ==============\n");
145  printf( "\n---> ls /mnt\n" );
146  ls( "/mnt" );
147  printf( "\n---> ls %s\n", RTEMS_NFS_LS_PATH );
148  ls( RTEMS_NFS_LS_PATH );
149
150  exit(0);
151
152  status = rtems_task_delete( RTEMS_SELF );
153}
154
Note: See TracBrowser for help on using the repository browser.