linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: tasleson@redhat.com
Cc: linux-nfs@vger.kernel.org, Steve Dickson <SteveD@redhat.com>
Subject: Re: [PATCH] exportfs: Return non-zero exit value on error
Date: Wed, 23 Oct 2013 12:44:44 +1100	[thread overview]
Message-ID: <20131023124444.65ace6e3@notabene.brown> (raw)
In-Reply-To: <52669862.6030409@redhat.com>

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

On Tue, 22 Oct 2013 10:23:14 -0500 Tony Asleson <tasleson@redhat.com> wrote:

> On 10/21/2013 05:25 PM, NeilBrown wrote:
> > On Wed,  2 Oct 2013 18:29:44 -0500 Tony Asleson <tasleson@redhat.com> wrote:
> > 
> >> To improve error handling when scripting exportfs it's useful
> >> to have non-zero exit codes when the requested operation did not
> >> succeed.
> >>
> >> This patch also returns a non-zero exit code if you request to
> >> unexport a non-existant share.
> >>
> >> Signed-off-by: Tony Asleson <tasleson@redhat.com>
> > 
> > This seems the have been forgotten, so maybe by replying to it someone will
> > notice (hi Steve).
> > 
> > Though I agree with the need for the patch, I don't much like it's shape.
> > 
> > Why change exportfs and unexportfs to return a status?  The status is only
> > used to set export_errno, and they sometimes set export_errno anyway, so why
> > not leave them returning  void and just setting export_errno as needed?
> 
> The reason I chose to return values was to make sure requested operation
> actually completed requested operation.  Unexporting a non-existent
> export is not considered an error and returns no indication you did
> absolutely nothing.

Hi,
 thanks makes sense - I had missed that (even though you explained it in the
 patch description :-( )

 With your patch, if asked to unexport something that wasn't exported it
 would not report any error, but would exit with an error status.  Is that
 correct?  I think I would rather have a message printed if there is an error.

 So would something like this (on top of my patch) address you need, or was
 there something else I missed?

Thanks,
NeilBrown

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 --]

  reply	other threads:[~2013-10-23  1:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-02 23:29 [PATCH] exportfs: Return non-zero exit value on error Tony Asleson
2013-10-21 22:25 ` NeilBrown
2013-10-22  8:38   ` Steve Dickson
2013-10-22 15:23   ` Tony Asleson
2013-10-23  1:44     ` NeilBrown [this message]
2013-10-23 17:36       ` Tony Asleson
2013-10-23 22:18         ` NeilBrown
2013-10-23 23:31           ` Chuck Lever
2013-10-24 15:56             ` Steve Dickson
2013-10-24 16:05               ` Chuck Lever
2013-10-28  3:39                 ` NeilBrown
2013-10-28 14:09                   ` Chuck Lever
2013-10-24  5:34           ` Tony Asleson
2013-10-22  8:30 ` Steve Dickson
2013-10-22  8:36   ` Steve Dickson
2013-10-28 22:35     ` NeilBrown
2013-11-04 15:33       ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131023124444.65ace6e3@notabene.brown \
    --to=neilb@suse.de \
    --cc=SteveD@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=tasleson@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).