summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/exportfs/exportfs.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 8c86790..cb81611 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -299,23 +299,13 @@ export_all(int verbose)
static void
-exportfs(char *arg, char *options, int verbose)
+exportfs_parsed(char *hname, char *path, char *options, int verbose)
{
struct exportent *eep;
nfs_export *exp = NULL;
struct addrinfo *ai = NULL;
- char *path;
- char *hname = arg;
int htype;
- if ((path = strchr(arg, ':')) != NULL)
- *path++ = '\0';
-
- if (!path || *path != '/') {
- xlog(L_ERROR, "Invalid exporting option: %s", arg);
- return;
- }
-
if ((htype = client_gettype(hname)) == MCL_FQDN) {
ai = host_addrinfo(hname);
if (ai != NULL) {
@@ -345,24 +335,38 @@ out:
freeaddrinfo(ai);
}
+static int exportfs_generic(char *arg, char *options, int verbose)
+{
+ char *path;
+
+ if ((path = strchr(arg, ':')) != NULL)
+ *path++ = '\0';
+
+ if (!path || *path != '/')
+ return 1;
+
+ exportfs_parsed(arg, path, options, verbose);
+ return 0;
+}
+
static void
-unexportfs(char *arg, int verbose)
+exportfs(char *arg, char *options, int verbose)
+{
+ int failed;
+
+ failed = exportfs_generic(arg, options, verbose);
+ if (failed)
+ xlog(L_ERROR, "Invalid export syntax: %s", arg);
+}
+
+static void
+unexportfs_parsed(char *hname, char *path, int verbose)
{
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);
- return;
- }
-
if ((htype = client_gettype(hname)) == MCL_FQDN) {
ai = host_addrinfo(hname);
if (ai)
@@ -403,11 +407,35 @@ unexportfs(char *arg, int verbose)
success = 1;
}
if (!success)
- xlog(L_ERROR, "Could not find '%s:%s' to unexport.", arg, path);
+ xlog(L_ERROR, "Could not find '%s:%s' to unexport.", hname, path);
freeaddrinfo(ai);
}
+static int unexportfs_generic(char *arg, int verbose)
+{
+ char *path;
+
+ if ((path = strchr(arg, ':')) != NULL)
+ *path++ = '\0';
+
+ if (!path || *path != '/')
+ return 1;
+
+ unexportfs_parsed(arg, path, verbose);
+ return 0;
+}
+
+static void
+unexportfs(char *arg, int verbose)
+{
+ int failed;
+
+ failed = unexportfs_generic(arg, verbose);
+ if (failed)
+ xlog(L_ERROR, "Invalid export syntax: %s", arg);
+}
+
static int can_test(void)
{
char buf[1024];