Changeset 99ae4eb in rtems-libbsd


Ignore:
Timestamp:
Oct 16, 2012, 6:38:09 PM (9 years ago)
Author:
Jennifer Averett <jennifer.averett@…>
Branches:
4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
Children:
b6ac989
Parents:
6bf75866
Message:

Added rtems exit code to ping, route, and ifconfig commands.

The rtems shell commands should not exit but allow multiple
command attempts and some of the commands share code that
will exit. For this reason a common exit routine was
provided and code added to err.h to address this.

allow access to it.

Location:
freebsd-userspace
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • freebsd-userspace/Makefile

    r6bf75866 r99ae4eb  
    150150C_FILES += rtems/rtems-uthread_kevent.c
    151151C_FILES += rtems/rtems-uthread_kqueue.c
     152C_FILES += rtems/rtems-shell.c
     153
    152154
    153155# ping command sources
  • freebsd-userspace/commands/sbin/ifconfig/ifconfig.c

    r6bf75866 r99ae4eb  
    127127static struct afswtch *af_getbyfamily(int af);
    128128static void af_other_status(int);
     129
     130#ifdef __rtems__
     131static int main_ifconfig(int argc, char *argv[]);
     132static int rtems_shell_main_ifconfig(int argc, char *argv[])
     133{
     134  rtems_shell_globals_t  ifconfig_globals;
     135  rtems_shell_globals = &ifconfig_globals;
     136  memset (rtems_shell_globals, 0, sizeof (ifconfig_globals));
     137  descr = NULL;
     138  descrlen = 64;
     139  newaddr = 1;
     140  supmedia = 0;
     141  printkeys = 0;       
     142  ifconfig_globals.exit_code = 1;
     143  if (setjmp (ifconfig_globals.exit_jmp) == 0)
     144    return main_ifconfig ( argc, argv);
     145  return ifconfig_globals.exit_code;
     146}
     147#endif
    129148
    130149#ifdef __rtems__
     
    12301249    "ifconfig [args]",             /* usage */
    12311250    "net",                         /* topic */
    1232     main_ifconfig,                 /* command */
     1251    rtems_shell_main_ifconfig,     /* command */
    12331252    NULL,                          /* alias */
    12341253    NULL                           /* next */
  • freebsd-userspace/commands/sbin/ping/ping.c

    r6bf75866 r99ae4eb  
    229229static void usage(void) __dead2;
    230230
     231#ifdef __rtems__
     232static int main_ping(int argc, char *const *argv);
     233static int rtems_shell_main_ping(int argc, char *argv[])
     234{
     235  rtems_shell_globals_t  ping_globals;
     236  rtems_shell_globals = &ping_globals;
     237  memset (rtems_shell_globals, 0, sizeof (ping_globals));
     238  BBELL = '\a';
     239  BSPACE = '\b';
     240  DOT = '.';
     241  icmp_type = ICMP_ECHO;
     242  icmp_type_rsp = ICMP_ECHOREPLY;
     243  phdr_len = 0;
     244  sweepmin = 0;
     245  sweepincr = 1;
     246  interval = 1000;
     247  waittime = MAXWAIT;
     248  nrcvtimeout = 0;
     249  tmin = 999999999.0;
     250  tmax = 0.0;
     251  tsum = 0.0;
     252  tsumsq = 0.0;
     253  ping_globals.exit_code = 1;
     254  if (setjmp (ping_globals.exit_jmp) == 0)
     255    return main_ping (argc, argv);
     256  return ping_globals.exit_code;
     257}
     258#endif
     259
     260
     261
    231262int
    232263#ifdef __rtems__
     
    520551                default:
    521552                        usage();
     553
    522554                }
    523555        }
     
    525557        if (argc - optind != 1)
    526558                usage();
     559
    527560        target = argv[optind];
    528561
     
    938971        }
    939972        finish();
     973#ifdef __rtems__
     974        /* RTEMS shell programs return -- they do not exit */
     975        if (nreceived)
     976                return(0);
     977        else
     978                return(2);
     979#endif
    940980        /* NOTREACHED */
    941981        exit(0);        /* Make the compiler happy */
     
    14351475                    tmin, avg, tmax, sqrt(vari));
    14361476        }
    1437 
     1477#ifndef __rtems__
    14381478        if (nreceived)
    14391479                exit(0);
    14401480        else
    14411481                exit(2);
     1482#endif
    14421483}
    14431484
     
    17381779usage()
    17391780{
    1740 
    17411781        (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
    17421782"usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
     
    17581798    "ping [args]",                 /* usage */
    17591799    "net",                         /* topic */
    1760     main_ping,                     /* command */
     1800    rtems_shell_main_ping,         /* command */
    17611801    NULL,                          /* alias */
    17621802    NULL                           /* next */
  • freebsd-userspace/commands/sbin/route/route.c

    r6bf75866 r99ae4eb  
    8181#endif
    8282
     83
    8384struct keytab {
    8485        char    *kt_cp;
     
    124125
    125126void usage(const char *) __dead2;
     127
     128#ifdef __rtems__
     129
     130static int main_route(int argc, char **argv);
     131
     132static int rtems_shell_main_route(int argc, char *argv[])
     133{
     134  rtems_shell_globals_t  route_globals;
     135  rtems_shell_globals = &route_globals;
     136  memset (rtems_shell_globals, 0, sizeof (route_globals));
     137  route_globals.exit_code = 1;
     138  if (setjmp (route_globals.exit_jmp) == 0)
     139    return main_route ( argc, argv);
     140  return route_globals.exit_code;
     141}
     142
     143#endif
     144
    126145
    127146void
     
    17041723    "route [args]",                /* usage */
    17051724    "net",                         /* topic */
    1706     main_route,                    /* command */
     1725    rtems_shell_main_route,        /* command */
    17071726    NULL,                          /* alias */
    17081727    NULL                           /* next */
  • freebsd-userspace/include/err.h

    r6bf75866 r99ae4eb  
    5353#endif
    5454
     55#ifdef __rtems__
     56#include <setjmp.h>
     57typedef struct  rtems_shell_globals_s {
     58  jmp_buf exit_jmp;
     59  int     exit_code;
     60} rtems_shell_globals_t;
     61extern rtems_shell_globals_t *rtems_shell_globals;
     62void rtems_shell_exit (int code);
     63
     64#define exit rtems_shell_exit
     65#endif
     66
     67
    5568__BEGIN_DECLS
    5669void    err(int, const char *, ...) __dead2 __printf0like(2, 3);
Note: See TracChangeset for help on using the changeset viewer.