diff options
Diffstat (limited to 'utils/exportfs/exportfs.c')
-rw-r--r-- | utils/exportfs/exportfs.c | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 6962444..da5fe21 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -35,8 +35,8 @@ #include "xlog.h" static void export_all(int verbose); -static int exportfs(char *arg, char *options, int verbose); -static int unexportfs(char *arg, int verbose); +static void exportfs(char *arg, char *options, int verbose); +static void unexportfs(char *arg, int verbose); static void exports_update(int verbose); static void dump(int verbose, int export_format); static void error(nfs_export *exp, int err); @@ -104,8 +104,6 @@ main(int argc, char **argv) xlog_stderr(1); xlog_syslog(0); - export_errno = 0; - while ((c = getopt(argc, argv, "afhio:ruvs")) != EOF) { switch(c) { case 'a': @@ -187,12 +185,8 @@ main(int argc, char **argv) if (f_all) export_all(f_verbose); else - for (i = optind; i < argc ; i++) { - if(!exportfs(argv[i], options, f_verbose)) { - /* Only flag a generic EINVAL if no errno is set */ - export_errno = (export_errno) ? export_errno : EINVAL; - } - } + for (i = optind; i < argc ; i++) + exportfs(argv[i], options, f_verbose); } /* If we are unexporting everything, then * don't care about what should be exported, as that @@ -205,12 +199,8 @@ main(int argc, char **argv) if (!f_reexport) xtab_export_read(); if (!f_export) - for (i = optind ; i < argc ; i++) { - if (!unexportfs(argv[i], f_verbose)) { - /* Only flag a generic EINVAL if no errno is set */ - export_errno = (export_errno) ? export_errno : EINVAL; - } - } + for (i = optind ; i < argc ; i++) + unexportfs(argv[i], f_verbose); if (!new_cache) rmtab_read(); } @@ -304,10 +294,9 @@ export_all(int verbose) } -static int +static void exportfs(char *arg, char *options, int verbose) { - int rc = 0; struct exportent *eep; nfs_export *exp = NULL; struct addrinfo *ai = NULL; @@ -320,8 +309,7 @@ exportfs(char *arg, char *options, int verbose) if (!path || *path != '/') { xlog(L_ERROR, "Invalid exporting option: %s", arg); - export_errno = EINVAL; - return rc; + return; } if ((htype = client_gettype(hname)) == MCL_FQDN) { @@ -349,29 +337,26 @@ exportfs(char *arg, char *options, int verbose) exp->m_warned = 0; validate_export(exp); - rc = 1; out: freeaddrinfo(ai); - return rc; } -static int +static void unexportfs(char *arg, int verbose) { - int rc = 0; nfs_export *exp; struct addrinfo *ai = NULL; char *path; char *hname = arg; int htype; + int success = 0; if ((path = strchr(arg, ':')) != NULL) *path++ = '\0'; if (!path || *path != '/') { xlog(L_ERROR, "Invalid unexporting option: %s", arg); - export_errno = EINVAL; - return rc; + return; } if ((htype = client_gettype(hname)) == MCL_FQDN) { @@ -411,13 +396,12 @@ unexportfs(char *arg, int verbose) #endif exp->m_xtabent = 0; exp->m_mayexport = 0; - rc = 1; + success = 1; } - if (!rc && verbose) + if (!success) xlog(L_ERROR, "Could not find '%s:%s' to unexport.", arg, path); freeaddrinfo(ai); - return rc; } static int can_test(void) @@ -746,7 +730,6 @@ error(nfs_export *exp, int err) { xlog(L_ERROR, "%s:%s: %s", exp->m_client->m_hostname, exp->m_export.e_path, strerror(err)); - export_errno = (export_errno) ? export_errno : err; } static void |