summaryrefslogtreecommitdiffstats
path: root/utils/exportfs/exportfs.c
diff options
context:
space:
mode:
authorPavel Raiskup <praiskup@redhat.com>2014-12-03 17:10:11 -0500
committerSteve Dickson <steved@redhat.com>2014-12-03 17:10:11 -0500
commitd6ef125c4be83de1d94727bf6be74cd7c0bf424c (patch)
tree81c1a3e6975958683128ce3b25afef278d0f268a /utils/exportfs/exportfs.c
parent72819502650d39e7791adebe737a6d04124d9ef3 (diff)
downloadnfs-utils-d6ef125c4be83de1d94727bf6be74cd7c0bf424c.tar.gz
nfs-utils-d6ef125c4be83de1d94727bf6be74cd7c0bf424c.tar.xz
nfs-utils-d6ef125c4be83de1d94727bf6be74cd7c0bf424c.zip
exportfs: warn when really nothing is exported
Throw 'No file systems exported!' iff no volume is exported rather then if some exports file is empty. Typically this can happen if the default /etc/exports file is empty and admin installed configuration into /etc/exports.d directory. This is follow-up for e725def62c73b4 commit. Signed-off-by: Pavel Raiskup <praiskup@redhat.com> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils/exportfs/exportfs.c')
-rw-r--r--utils/exportfs/exportfs.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 92fb9eb..48eac00 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, int verbose);
+static int export_d_read(const char *dname);
static void grab_lockfile(void);
static void release_lockfile(void);
@@ -182,8 +182,11 @@ main(int argc, char **argv)
atexit(release_lockfile);
if (f_export && ! f_ignore) {
- export_read(_PATH_EXPORTS, f_verbose);
- export_d_read(_PATH_EXPORTS_D, f_verbose);
+ 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)
@@ -685,21 +688,22 @@ out:
/* Based on mnt_table_parse_dir() in
util-linux-ng/shlibs/mount/src/tab_parse.c */
-static void
-export_d_read(const char *dname, int verbose)
+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];
@@ -729,14 +733,14 @@ export_d_read(const char *dname, int verbose)
continue;
}
- export_read(fname, verbose);
+ volumes += export_read(fname);
}
for (i = 0; i < n; i++)
free(namelist[i]);
free(namelist);
- return;
+ return volumes;
}
static char