From 77ca6f25393457f627a9ddda457c6ce5b18a5a98 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Fri, 14 Jan 2005 04:50:38 +0000 Subject: [PATCH] * amd/get_args.c (show_usage): separate function to print usage string. (get_args) Call show_usage() from get_args when needed, then exit. * amd/get_args.c (get_version_string): print also domain, host, and hostd. (get_args): print version string at the very end, after all other values had been initialized. Patch from Christos Zoulas . --- AUTHORS | 3 +- ChangeLog | 10 ++++++ NEWS | 3 ++ amd/get_args.c | 96 ++++++++++++++++++++++++++++++-------------------- 4 files changed, 73 insertions(+), 39 deletions(-) diff --git a/AUTHORS b/AUTHORS index bf0f023..499008e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -177,7 +177,8 @@ local media mounts. October 12, 2004: patch to support two new amd.conf options, domain_strip and auto_attrcache. Patch to cleanup NFS attribute-cache flag computation. Patch to fix an inconsistency in timeouts in the RPC code between socket and -TLI implementations. +TLI implementations. Patch to print version string (amd -v) after all +options had been initialized, so we can print domain, host, and hostd. * Bill Paul diff --git a/ChangeLog b/ChangeLog index d8a868c..47d5c63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2005-01-13 Erez Zadok + * amd/get_args.c (show_usage): separate function to print usage + string. + (get_args) Call show_usage() from get_args when needed, then exit. + + * amd/get_args.c (get_version_string): print also domain, host, + and hostd. + (get_args): print version string at the very end, after all other + values had been initialized. Patch from Christos Zoulas + . + * conf/transp/transp_sockets.c (check_pmap_up, get_nfs_version), conf/transp/transp_tli.c (check_pmap_up): correct an inconsistency in timeouts in the RPC code between socket and TLI diff --git a/NEWS b/NEWS index 65c47b6..59d0b24 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,9 @@ - support escaped slashes, needed for SMB mounts. Use '\\\/\\\/' in a string to get a double slash. +- amd -v now prints domain, host, and hostd values: foo, example.com, and + foo.example.com, respectively. + - bugs fixed: * various memory management problems (leaks, etc) * fixed nfsx support diff --git a/amd/get_args.c b/amd/get_args.c index 28f20c6..72a94d6 100644 --- a/amd/get_args.c +++ b/amd/get_args.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: get_args.c,v 1.24 2005/01/03 20:56:45 ezk Exp $ + * $Id: get_args.c,v 1.25 2005/01/14 04:50:38 ezk Exp $ * */ @@ -60,6 +60,7 @@ int usage = 0; int use_conf_file = 0; /* default don't use amd.conf file */ char *mnttab_file_name = NULL; /* symbol must be available always */ + /* * Return the version string (dynamic buffer) */ @@ -98,6 +99,8 @@ get_version_string(void) strcat(vers, tmpbuf); sprintf(tmpbuf, "full_os=%s, os=%s, osver=%s, vendor=%s.\n", gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor); + sprintf(tmpbuf, "domain=%s, host=%s, hostd=%s.\n", + hostdomain, am_get_hostname(), hostd); strcat(vers, tmpbuf); strcat(vers, "Map support for: "); @@ -120,6 +123,40 @@ get_version_string(void) } +static void +show_usage(void) +{ + fprintf(stderr, + "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\ +\t[-k kernel_arch] [-l logfile%s\n\ +\t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\ +\t[-o op_sys_ver] [-O op_sys_name]\n\ +\t[-F conf_file] [-T conf_tag]", am_get_progname(), +#ifdef HAVE_SYSLOG +# ifdef LOG_DAEMON + "|\"syslog[:facility]\"]" +# else /* not LOG_DAEMON */ + "|\"syslog\"]" +# endif /* not LOG_DAEMON */ +#else /* not HAVE_SYSLOG */ + "]" +#endif /* not HAVE_SYSLOG */ + ); + +#ifdef HAVE_MAP_NIS + fputs(" [-y nis-domain]\n", stderr); +#else /* not HAVE_MAP_NIS */ + fputc('\n', stderr); +#endif /* HAVE_MAP_NIS */ + + show_opts('x', xlog_opt); +#ifdef DEBUG + show_opts('D', dbg_opt); +#endif /* DEBUG */ + fprintf(stderr, "\t[directory mapname [-map_options]] ...\n"); +} + + void get_args(int argc, char *argv[]) { @@ -127,6 +164,7 @@ get_args(int argc, char *argv[]) FILE *fp = stdin; char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:"; char *getopt_args; + int print_version = 0; /* 1 means we should print version info */ #ifdef HAVE_GNU_GETOPT getopt_args = getopt_arguments; @@ -201,8 +239,11 @@ get_args(int argc, char *argv[]) break; case 'v': - fputs(get_version_string(), stderr); - exit(0); + /* + * defer to print version info after every variable had been + * initialized. + */ + print_version++; break; case 'w': @@ -246,7 +287,8 @@ get_args(int argc, char *argv[]) break; case 'H': - goto show_usage; + show_usage(); + exit(1); break; case 'O': @@ -306,8 +348,10 @@ get_args(int argc, char *argv[]) } #endif /* HAVE_MAP_LDAP */ - if (usage) - goto show_usage; + if (usage) { + show_usage(); + exit(1); + } while (optind <= argc - 2) { char *dir = argv[optind++]; @@ -352,10 +396,10 @@ get_args(int argc, char *argv[]) * If the kernel architecture was not specified * then use the machine architecture. */ - if (gopt.karch == 0) + if (gopt.karch == NULL) gopt.karch = gopt.arch; - if (gopt.cluster == 0) + if (gopt.cluster == NULL) gopt.cluster = hostdomain; if (gopt.amfs_auto_timeo <= 0) @@ -364,37 +408,13 @@ get_args(int argc, char *argv[]) gopt.amfs_auto_retrans = AMFS_AUTO_RETRANS; if (gopt.amfs_auto_retrans <= 0) gopt.amfs_auto_retrans = 3; /* XXX */ - return; } -show_usage: - fprintf(stderr, - "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\ -\t[-k kernel_arch] [-l logfile%s\n\ -\t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\ -\t[-o op_sys_ver] [-O op_sys_name]\n\ -\t[-F conf_file] [-T conf_tag]", am_get_progname(), -#ifdef HAVE_SYSLOG -# ifdef LOG_DAEMON - "|\"syslog[:facility]\"]" -# else /* not LOG_DAEMON */ - "|\"syslog\"]" -# endif /* not LOG_DAEMON */ -#else /* not HAVE_SYSLOG */ - "]" -#endif /* not HAVE_SYSLOG */ - ); - -#ifdef HAVE_MAP_NIS - fputs(" [-y nis-domain]\n", stderr); -#else /* not HAVE_MAP_NIS */ - fputc('\n', stderr); -#endif /* HAVE_MAP_NIS */ + /* finally print version string and exit, if asked for */ + if (print_version) { + fputs(get_version_string(), stderr); + exit(0); + } - show_opts('x', xlog_opt); -#ifdef DEBUG - show_opts('D', dbg_opt); -#endif /* DEBUG */ - fprintf(stderr, "\t[directory mapname [-map_options]] ...\n"); - exit(1); + return; } -- 2.43.0