Skip to contentSkip to conversation

exportfs: drop extra newline in xlog

PATCH In review Mike Frysinger 3 participants 6 messages Sep 1, 2011 – Sep 2, 2011

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 2/2 exportfs: do not warn if /etc/exports.d/ does not exist

In reply to Mike Frysinger

It isn't uncommon for /etc/exports.d/ to not exist, and imo, it's not that big of a deal as often times, a simple /etc/exports is sufficient. So silently skip the case where the dir is missing.

---
 utils/exportfs/exportfs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +5 -2
index 986a272..7432a65 100644
@@ -529,9 +529,12 @@ export_d_read(const char *dname)
 
 
 	n = scandir(dname, &namelist, NULL, versionsort);
-	if (n < 0)
+	if (n < 0) {
+		if (errno == ENOENT)
+			/* Silently return */
+			return;
 		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
-	else if (n == 0)
+	} else if (n == 0)
 		return;
 
 	for (i = 0; i < n; i++) {
Signature · 1 line
1.7.6
#0 lore raw

PATCH 1/2 exportfs: drop extra newline in xlog

Since xlog() itself appends a newline, we don't want to add our own otherwise we get extra in the output.

---
 utils/exportfs/exportfs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
utils/exportfs/exportfs.c +4 -4
index 12e8bf1..986a272 100644
@@ -401,7 +401,7 @@ validate_export(nfs_export *exp)
 	int fs_has_fsid = 0;
 
 	if (stat(path, &stb) < 0) {
-		xlog(L_ERROR, "Failed to stat %s: %m \n", path);
+		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		return;
 	}
 	if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) {
@@ -530,7 +530,7 @@ export_d_read(const char *dname)
 
 	n = scandir(dname, &namelist, NULL, versionsort);
 	if (n < 0)
-		xlog(L_NOTICE, "scandir %s: %s\n", dname, strerror(errno));
+		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
 	else if (n == 0)
 		return;
 
@@ -558,7 +558,7 @@ export_d_read(const char *dname)
 
 		fname_len = snprintf(fname, PATH_MAX +1, "%s/%s", dname, d->d_name);
 		if (fname_len > PATH_MAX) {
-			xlog(L_WARNING, "Too long file name: %s in %s\n", d->d_name, dname);
+			xlog(L_WARNING, "Too long file name: %s in %s", d->d_name, dname);
 			continue;
 		}
 
@@ -672,7 +672,7 @@ dump(int verbose)
 static void
 error(nfs_export *exp, int err)
 {
-	xlog(L_ERROR, "%s:%s: %s\n", exp->m_client->m_hostname,
+	xlog(L_ERROR, "%s:%s: %s", exp->m_client->m_hostname,
 		exp->m_export.e_path, strerror(err));
 }
 
Signature · 1 line
1.7.6
#5 lore raw
Quoted 4 lines · Mike Frysinger

Since xlog() itself appends a newline, we don't want to add our own otherwise we get extra in the output.

Committed...

steved.

Quoted 44 lines
---
 utils/exportfs/exportfs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
utils/exportfs/exportfs.c +4 -4
index 12e8bf1..986a272 100644
@@ -401,7 +401,7 @@ validate_export(nfs_export *exp)
 	int fs_has_fsid = 0;
 
 	if (stat(path, &stb) < 0) {
-		xlog(L_ERROR, "Failed to stat %s: %m \n", path);
+		xlog(L_ERROR, "Failed to stat %s: %m", path);
 		return;
 	}
 	if (!S_ISDIR(stb.st_mode) && !S_ISREG(stb.st_mode)) {
@@ -530,7 +530,7 @@ export_d_read(const char *dname)
 
 	n = scandir(dname, &namelist, NULL, versionsort);
 	if (n < 0)
-		xlog(L_NOTICE, "scandir %s: %s\n", dname, strerror(errno));
+		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
 	else if (n == 0)
 		return;
 
@@ -558,7 +558,7 @@ export_d_read(const char *dname)
 
 		fname_len = snprintf(fname, PATH_MAX +1, "%s/%s", dname, d->d_name);
 		if (fname_len > PATH_MAX) {
-			xlog(L_WARNING, "Too long file name: %s in %s\n", d->d_name, dname);
+			xlog(L_WARNING, "Too long file name: %s in %s", d->d_name, dname);
 			continue;
 		}
 
@@ -672,7 +672,7 @@ dump(int verbose)
 static void
 error(nfs_export *exp, int err)
 {
-	xlog(L_ERROR, "%s:%s: %s\n", exp->m_client->m_hostname,
+	xlog(L_ERROR, "%s:%s: %s", exp->m_client->m_hostname,
 		exp->m_export.e_path, strerror(err));
 }
 
#2 lore raw

Re: [PATCH 2/2] exportfs: do not warn if /etc/exports.d/ does not exist

In reply to Mike Frysinger
Quoted 5 lines · Mike Frysinger

It isn't uncommon for /etc/exports.d/ to not exist, and imo, it's not that big of a deal as often times, a simple /etc/exports is sufficient. So silently skip the case where the dir is missing.

Committed...

steved.

Quoted 23 lines
---
 utils/exportfs/exportfs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +5 -2
index 986a272..7432a65 100644
@@ -529,9 +529,12 @@ export_d_read(const char *dname)
 
 
 	n = scandir(dname, &namelist, NULL, versionsort);
-	if (n < 0)
+	if (n < 0) {
+		if (errno == ENOENT)
+			/* Silently return */
+			return;
 		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
-	else if (n == 0)
+	} else if (n == 0)
 		return;
 
 	for (i = 0; i < n; i++) {
#3 lore raw

Re: [PATCH 2/2] exportfs: do not warn if /etc/exports.d/ does not exist

I've tried this issue in different way:)
Steve, could you see this bug?

      https://bugzilla.redhat.com/show_bug.cgi?id=697006

Masatake YAMATO

On Thu, 01 Sep 2011 11:35:56 -0400, Steve Dickson <[email protected]> wrote

Quoted 39 lines · Mike Frysinger
Quoted 5 lines

It isn't uncommon for /etc/exports.d/ to not exist, and imo, it's not that big of a deal as often times, a simple /etc/exports is sufficient. So silently skip the case where the dir is missing.

Committed...

steved.

Quoted 13 lines
---
 utils/exportfs/exportfs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +0 -1
index 986a272..7432a65 100644
@@ -529,9 +529,12 @@ export_d_read(const char *dname)
 
 
 	n = scandir(dname, &namelist, NULL, versionsort);
-	if (n < 0)

utils/exportfs/exportfs.c export_d_read(const char *dname) · line 540

Quoted 10 lines
utils/exportfs/exportfs.c +5 -1
+	if (n < 0) {
+		if (errno == ENOENT)
+			/* Silently return */
+			return;
 		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
-	else if (n == 0)
+	} else if (n == 0)
 		return;
 
 	for (i = 0; i < n; i++) {

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw

Re: [PATCH 2/2] exportfs: do not warn if /etc/exports.d/ does not exist

Quoted 4 lines · Masatake YAMATO

I've tried this issue in different way:)
Steve, could you see this bug?

      https://bugzilla.redhat.com/show_bug.cgi?id=697006

Fair enough.... but the patch in that bz is distro specific, means it would have no affect on other distros... With that said, your patch is a good idea so I will added my todo list

steved.

Quoted 44 lines

Masatake YAMATO

On Thu, 01 Sep 2011 11:35:56 -0400, Steve Dickson <[email protected]> wrote

Quoted 39 lines · Mike Frysinger
Quoted 5 lines

It isn't uncommon for /etc/exports.d/ to not exist, and imo, it's not that big of a deal as often times, a simple /etc/exports is sufficient. So silently skip the case where the dir is missing.

Committed...

steved.

Quoted 13 lines
---
 utils/exportfs/exportfs.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
utils/exportfs/exportfs.c +0 -1
index 986a272..7432a65 100644
@@ -529,9 +529,12 @@ export_d_read(const char *dname)
 
 
 	n = scandir(dname, &namelist, NULL, versionsort);
-	if (n < 0)

utils/exportfs/exportfs.c export_d_read(const char *dname) · line 540

Quoted 10 lines
utils/exportfs/exportfs.c +5 -1
+	if (n < 0) {
+		if (errno == ENOENT)
+			/* Silently return */
+			return;
 		xlog(L_NOTICE, "scandir %s: %s", dname, strerror(errno));
-	else if (n == 0)
+	} else if (n == 0)
 		return;
 
 	for (i = 0; i < n; i++) {

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html