linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH - nfs-utils] exportfs: report failure if asked to unexport something not exported.
@ 2013-10-28  3:43 NeilBrown
  2013-10-28 12:47 ` Steve Dickson
  0 siblings, 1 reply; 3+ messages in thread
From: NeilBrown @ 2013-10-28  3:43 UTC (permalink / raw)
  To: Steve Dickson; +Cc: Tony Asleson, NFS

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]



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.

Reported-by: Tony Asleson <tasleson@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 52fc03d..c9e12db 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -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);
 }

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH - nfs-utils] exportfs: report failure if asked to unexport something not exported.
  2013-10-28  3:43 [PATCH - nfs-utils] exportfs: report failure if asked to unexport something not exported NeilBrown
@ 2013-10-28 12:47 ` Steve Dickson
  2013-10-28 18:29   ` Steve Dickson
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Dickson @ 2013-10-28 12:47 UTC (permalink / raw)
  To: NeilBrown; +Cc: Tony Asleson, NFS

Hello,

On 27/10/13 23:43, NeilBrown wrote:
> 
> 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.
> 
> Reported-by: Tony Asleson <tasleson@redhat.com>
> Signed-off-by: NeilBrown <neilb@suse.de>
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index 52fc03d..c9e12db 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -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);
>  }
> 
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.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 utils/exportfs/exportfs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 318deb3..6962444 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -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.

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH - nfs-utils] exportfs: report failure if asked to unexport something not exported.
  2013-10-28 12:47 ` Steve Dickson
@ 2013-10-28 18:29   ` Steve Dickson
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Dickson @ 2013-10-28 18:29 UTC (permalink / raw)
  To: Steve Dickson; +Cc: NeilBrown, Tony Asleson, NFS



On 28/10/13 08:47, Steve Dickson wrote:
> Hello,
> 
> On 27/10/13 23:43, NeilBrown wrote:
>>
>> 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.
>>
>> Reported-by: Tony Asleson <tasleson@redhat.com>
>> Signed-off-by: NeilBrown <neilb@suse.de>
>>
>> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
>> index 52fc03d..c9e12db 100644
>> --- a/utils/exportfs/exportfs.c
>> +++ b/utils/exportfs/exportfs.c
>> @@ -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);
>>  }
>>
> 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.
> 
> Signed-off-by: Steve Dickson <steved@redhat.com>
Committed...

steved.

> ---
>  utils/exportfs/exportfs.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
> index 318deb3..6962444 100644
> --- a/utils/exportfs/exportfs.c
> +++ b/utils/exportfs/exportfs.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-28 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-28  3:43 [PATCH - nfs-utils] exportfs: report failure if asked to unexport something not exported NeilBrown
2013-10-28 12:47 ` Steve Dickson
2013-10-28 18:29   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).