Changeset e6405ea in rtems-libbsd


Ignore:
Timestamp:
Nov 10, 2014, 7:27:55 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, c1e05b9ea378b2971e3d7704779112b4bc4296da, freebsd-9.3, 4a77611a223ea883fb548679b516d326a020d447
Children:
91ea7ea
Parents:
026abfb
git-author:
Sebastian Huber <sebastian.huber@…> (11/10/14 07:27:55)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/20/14 07:33:08)
Message:

HOSTNAME(1): Add -m flag

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • freebsd/bin/hostname/hostname.c

    r026abfb re6405ea  
    4747#include <machine/rtems-bsd-program.h>
    4848#include <machine/rtems-bsd-commands.h>
     49#include <rtems/mdns.h>
    4950#endif /* __rtems__ */
    5051#include <sys/cdefs.h>
     
    7980rtems_shell_cmd_t rtems_shell_HOSTNAME_Command = {
    8081  .name = "hostname",
    81   .usage = "hostname [-fs] [name-of-host]",
     82  .usage = "hostname [-fms] [name-of-host]",
    8283  .topic = "net",
    8384  .command = hostname_command
     
    9495#define optind getopt_data.optind
    9596#define getopt(argc, argv, opt) getopt_r(argc, argv, "+" opt, &getopt_data)
     97        int mflag = 0;
    9698#endif /* __rtems__ */
    9799
    98100        sflag = 0;
     101#ifndef __rtems__
    99102        while ((ch = getopt(argc, argv, "fs")) != -1)
     103#else /* __rtems__ */
     104        while ((ch = getopt(argc, argv, "fms")) != -1)
     105#endif /* __rtems__ */
    100106                switch (ch) {
    101107                case 'f':
     
    109115                        sflag = 1;
    110116                        break;
     117#ifdef __rtems__
     118                case 'm':
     119                        mflag = 1;
     120                        break;
     121#endif /* __rtems__ */
    111122                case '?':
    112123                default:
     
    120131
    121132        if (*argv) {
     133#ifdef __rtems__
     134                if (mflag) {
     135                        if (rtems_mdns_sethostname(*argv)) {
     136                                err(1, "rtems_mdns_sethostname");
     137                        }
     138                } else {
     139#endif /* __rtems__ */
    122140                if (sethostname(*argv, (int)strlen(*argv)))
    123141                        err(1, "sethostname");
     142#ifdef __rtems__
     143                }
     144        } else if (mflag) {
     145                if (rtems_mdns_gethostname(hostname, sizeof(hostname))) {
     146                        err(1, "rtems_mdns_gethostname");
     147                }
     148
     149                (void)printf("%s\n", hostname);
     150#endif /* __rtems__ */
    124151        } else {
    125152                if (gethostname(hostname, (int)sizeof(hostname)))
     
    139166{
    140167
    141         (void)fprintf(stderr, "usage: hostname [-fs] [name-of-host]\n");
     168        (void)fprintf(stderr, "usage: hostname [-fms] [name-of-host]\n");
    142169        exit(1);
    143170}
  • libbsd.txt

    r026abfb re6405ea  
    285285IFF_DRV_RUNNING is set in case the link is up, otherwise ether_output() will
    286286return the error status ENETDOWN.
     287
     288== Shell Commands
     289
     290=== HOSTNAME(1)
     291
     292In addition to the standard options the RTEMS version of the HOSTNAME(1)
     293command supports the -m flag to set/get the multicast hostname of the
     294mDNS resolver instance.  See also rtems_mdns_sethostname() and
     295rtems_mdns_gethostname().
    287296
    288297== Issues and TODO
Note: See TracChangeset for help on using the changeset viewer.