Skip to contentSkip to conversation

exportfs: report failure if asked to unexport something not exported.

PATCH In review NeilBrown 2 participants 3 messages Oct 28, 2013

Subsystems (2)
lore
Share & tools
lore

NeilBrown

author
#0 lore raw

PATCH 1/1 exportfs: report failure if asked to unexport something not exported.

Currently if exportfs is asked to unexport something that is not exported it silently succeeds. This is not ideal, particularly for scripting situations.

So report an error unless the unexport was successful.

utils/exportfs/exportfs.c +4 -0
index 52fc03d..c9e12db 100644
@@ -351,6 +351,7 @@ unexportfs(char *arg, int verbose)
 	char		*path;
 	char		*hname = arg;
 	int		htype;
+	int		success = 0;
 
 	if ((path = strchr(arg, ':')) != NULL)
 		*path++ = '\0';
@@ -397,7 +398,10 @@ unexportfs(char *arg, int verbose)
 #endif
 		exp->m_xtabent = 0;
 		exp->m_mayexport = 0;
+		success = 1;
 	}
+	if (!success)
+		xlog(L_ERROR, "Could not find %s to unexport.\n", arg);
 
 	freeaddrinfo(ai);
 }
#1 lore raw

Hello,

Quoted 24 lines · NeilBrown

Currently if exportfs is asked to unexport something that is not exported it silently succeeds. This is not ideal, particularly for scripting situations.

So report an error unless the unexport was successful.

utils/exportfs/exportfs.c +1 -0
index 52fc03d..c9e12db 100644
@@ -351,6 +351,7 @@ unexportfs(char *arg, int verbose)
 	char		*path;
 	char		*hname = arg;
 	int		htype;
+	int		success = 0;
 
 	if ((path = strchr(arg, ':')) != NULL)
 		*path++ = '\0';

utils/exportfs/exportfs.c unexportfs(char *arg, int verbose) · line 407

Quoted 10 lines
utils/exportfs/exportfs.c +3 -0
@@ -397,7 +398,10 @@ unexportfs(char *arg, int verbose)
 #endif
 		exp->m_xtabent = 0;
 		exp->m_mayexport = 0;
+		success = 1;
 	}
+	if (!success)
+		xlog(L_ERROR, "Could not find %s to unexport.\n", arg);
 
 	freeaddrinfo(ai);
 }

This does not apply due commit 232eb7ad0... But I agree with doing a xlog on failures but I would like to cover it with the -v flag... Something similar to :

[PATCH] exportfs: report failure if asked to unexport something not exported.

Currently if exportfs is asked to unexport something that is not exported it silently succeeds. This is not ideal, particularly for scripting situations.

So report an error when the unexport was successful and the -v flag used.

---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)
utils/exportfs/exportfs.c +2 -0
index 318deb3..6962444 100644
@@ -413,6 +413,8 @@ unexportfs(char *arg, int verbose)
        exp->m_mayexport = 0;
        rc = 1;
    }
+   if (!rc && verbose)
+       xlog(L_ERROR, "Could not find '%s:%s' to unexport.", arg, path);
 
    freeaddrinfo(ai);
    return rc;

steved.

#2 lore raw
Quoted 43 lines · Steve Dickson

Hello,

Quoted 24 lines · NeilBrown

Currently if exportfs is asked to unexport something that is not exported it silently succeeds. This is not ideal, particularly for scripting situations.

So report an error unless the unexport was successful.

utils/exportfs/exportfs.c +1 -0
index 52fc03d..c9e12db 100644
@@ -351,6 +351,7 @@ unexportfs(char *arg, int verbose)
 	char		*path;
 	char		*hname = arg;
 	int		htype;
+	int		success = 0;
 
 	if ((path = strchr(arg, ':')) != NULL)
 		*path++ = '\0';

utils/exportfs/exportfs.c unexportfs(char *arg, int verbose) · line 407

Quoted 10 lines
utils/exportfs/exportfs.c +3 -0
@@ -397,7 +398,10 @@ unexportfs(char *arg, int verbose)
 #endif
 		exp->m_xtabent = 0;
 		exp->m_mayexport = 0;
+		success = 1;
 	}
+	if (!success)
+		xlog(L_ERROR, "Could not find %s to unexport.\n", arg);
 
 	freeaddrinfo(ai);
 }

This does not apply due commit 232eb7ad0... But I agree with doing a xlog on failures but I would like to cover it with the -v flag... Something similar to :

[PATCH] exportfs: report failure if asked to unexport something not exported.

Quoted 7 lines

Currently if exportfs is asked to unexport something that is not exported it silently succeeds. This is not ideal, particularly for scripting situations.

So report an error when the unexport was successful and the -v flag used.

Committed...

steved.

Quoted 25 lines
---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)
utils/exportfs/exportfs.c +2 -0
index 318deb3..6962444 100644
@@ -413,6 +413,8 @@ unexportfs(char *arg, int verbose)
        exp->m_mayexport = 0;
        rc = 1;
    }
+   if (!rc && verbose)
+       xlog(L_ERROR, "Could not find '%s:%s' to unexport.", arg, path);
 
    freeaddrinfo(ai);
    return rc;

steved.
--
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