You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.2 KiB
119 lines
3.2 KiB
diff --git a/support/export/export.c b/support/export/export.c |
|
index ce714d4..e1bebce 100644 |
|
--- a/support/export/export.c |
|
+++ b/support/export/export.c |
|
@@ -69,8 +69,9 @@ static void warn_duplicated_exports(nfs_export *exp, struct exportent *eep) |
|
* export_read - read entries from /etc/exports |
|
* @fname: name of file to read from |
|
* |
|
+ * Returns number of read entries. |
|
*/ |
|
-void |
|
+int |
|
export_read(char *fname) |
|
{ |
|
struct exportent *eep; |
|
@@ -82,16 +83,16 @@ export_read(char *fname) |
|
while ((eep = getexportent(0,1)) != NULL) { |
|
exp = export_lookup(eep->e_hostname, eep->e_path, 0); |
|
if (!exp) { |
|
- exp = export_create(eep, 0); |
|
- if (exp) |
|
+ if (export_create(eep, 0)) |
|
+ /* possible complaints already logged */ |
|
volumes++; |
|
} |
|
else |
|
warn_duplicated_exports(exp, eep); |
|
} |
|
endexportent(); |
|
- if (volumes == 0) |
|
- xlog(L_ERROR, "No file systems exported!"); |
|
+ |
|
+ return volumes; |
|
} |
|
|
|
/** |
|
diff --git a/support/include/exportfs.h b/support/include/exportfs.h |
|
index 97b2327..faa9f0b 100644 |
|
--- a/support/include/exportfs.h |
|
+++ b/support/include/exportfs.h |
|
@@ -133,7 +133,7 @@ struct addrinfo * client_resolve(const struct sockaddr *sap); |
|
int client_member(const char *client, |
|
const char *name); |
|
|
|
-void export_read(char *fname); |
|
+int export_read(char *fname); |
|
void export_reset(nfs_export *); |
|
nfs_export * export_lookup(char *hname, char *path, int caconical); |
|
nfs_export * export_find(const struct addrinfo *ai, |
|
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c |
|
index c06f2aa..b7d8578 100644 |
|
--- a/utils/exportfs/exportfs.c |
|
+++ b/utils/exportfs/exportfs.c |
|
@@ -47,7 +47,7 @@ static void error(nfs_export *exp, int err); |
|
static void usage(const char *progname, int n); |
|
static void validate_export(nfs_export *exp); |
|
static int matchhostname(const char *hostname1, const char *hostname2); |
|
-static void export_d_read(const char *dname); |
|
+static int export_d_read(const char *dname); |
|
static void grab_lockfile(void); |
|
static void release_lockfile(void); |
|
|
|
@@ -185,8 +185,11 @@ main(int argc, char **argv) |
|
atexit(release_lockfile); |
|
|
|
if (f_export && ! f_ignore) { |
|
- export_read(_PATH_EXPORTS); |
|
- export_d_read(_PATH_EXPORTS_D); |
|
+ if (! (export_read(_PATH_EXPORTS) + |
|
+ export_d_read(_PATH_EXPORTS_D))) { |
|
+ if (f_verbose) |
|
+ xlog(L_WARNING, "No file systems exported!"); |
|
+ } |
|
} |
|
if (f_export) { |
|
if (f_all) |
|
@@ -699,21 +702,22 @@ out: |
|
|
|
/* Based on mnt_table_parse_dir() in |
|
util-linux-ng/shlibs/mount/src/tab_parse.c */ |
|
-static void |
|
+static int |
|
export_d_read(const char *dname) |
|
{ |
|
int n = 0, i; |
|
struct dirent **namelist = NULL; |
|
+ int volumes = 0; |
|
|
|
|
|
n = scandir(dname, &namelist, NULL, versionsort); |
|
if (n < 0) { |
|
if (errno == ENOENT) |
|
/* Silently return */ |
|
- return; |
|
+ return volumes; |
|
xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno)); |
|
} else if (n == 0) |
|
- return; |
|
+ return volumes; |
|
|
|
for (i = 0; i < n; i++) { |
|
struct dirent *d = namelist[i]; |
|
@@ -743,14 +747,14 @@ export_d_read(const char *dname) |
|
continue; |
|
} |
|
|
|
- export_read(fname); |
|
+ volumes += export_read(fname); |
|
} |
|
|
|
for (i = 0; i < n; i++) |
|
free(namelist[i]); |
|
free(namelist); |
|
|
|
- return; |
|
+ return volumes; |
|
} |
|
|
|
static char
|
|
|