source: network-demos/nfsClientTest/init.c @ 5c0f2e9

4.11network-demos-4-10-branchnetwork-demos-4-9-branch
Last change on this file since 5c0f2e9 was 591682d, checked in by Joel Sherrill <joel.sherrill@…>, on 09/25/07 at 16:06:59

2007-09-25 Joel Sherrill <joel.sherrill@…>

  • .cvsignore, Makefile, init.c: Switch to using rtems-bin2c for initial filesystem image.
  • Property mode set to 100644
File size: 3.7 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/untar.h>
54
55     
56#include <rtems/error.h>
57#include <rpc/rpc.h>
58#include <netinet/in.h>
59#include <time.h>
60
61#include <arpa/inet.h>
62#include <sys/socket.h>
63#include "../networkconfig.h"
64
65
66/*
67 *  The tarfile image is built automatically externally.
68 */
69#include "FilesystemImage.h"
70
71rtems_task Init(
72  rtems_task_argument argument
73)
74{
75  rtems_status_code status;
76  int int_status;
77
78  printf("\n\n*** NFS Client TEST ***\n\r" );
79
80  printf( "Free space %d\n", malloc_free_space() );
81  /*
82   * Load filesystem image
83   */
84  printf("=============== Loading filesystem image ===============\n");
85  status = Untar_FromMemory((void *)FilesystemImage, FilesystemImage_size);
86   
87  printf("============== Look at Local Filesystem ==============\n");
88  printf( "PWD: " );
89  pwd();
90 
91  printf( "\n--->ls /\n" );
92  ls("/");
93
94  printf( "\n--->ls /etc\n" );
95  ls("/etc");
96
97  printf("============== Initializing Network ==============\n");
98  rtems_bsdnet_initialize_network ();
99
100  printf("============== Add Route ==============\n");
101  rtems_bsdnet_show_inet_routes ();
102
103  printf("============== Initializing RPC ==============\n");
104  int_status = rpcUdpInit();
105  if ( int_status )
106    printf( "RPC UDP Initialization failed\n" );
107
108  printf("============== Initializing NFS Subsystem ==============\n");
109  nfsInit( 0, 0 );
110
111  printf("============== Mounting Remote Filesystem ==============\n");
112#if 1
113  /* This code uses the NFS mount wrapper function */
114  int_status = nfsMount( RTEMS_NFS_SERVER, RTEMS_NFS_SERVER_PATH, "/mnt" );
115#else
116  /* This section does it more explicitly */
117  mkdir( "/mnt", 0777 );
118  int_status = mount(
119    NULL,                        /* mount_table_entry_pointer */
120    &nfs_fs_ops,                 /* filesystem_operations_table_pointer */
121    RTEMS_FILESYSTEM_READ_WRITE, /* options */
122                                 /* device aka remote filesystem */
123    RTEMS_NFS_SERVER ":" RTEMS_NFS_SERVER_PATH,
124    "/mnt"                       /* mount_point */
125  );
126#endif
127  if ( int_status )
128    printf( "NFS Mount failed -- %s\n", strerror(errno) );
129
130  printf("============== Look at Remote Filesystem ==============\n");
131  printf( "\n---> ls /mnt\n" );
132  ls( "/mnt" );
133  printf( "\n---> ls %s\n", RTEMS_NFS_LS_PATH );
134  ls( RTEMS_NFS_LS_PATH );
135
136  exit(0);
137
138  status = rtems_task_delete( RTEMS_SELF );
139}
140
Note: See TracBrowser for help on using the repository browser.