From patchwork Wed Oct 23 01:44:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 3085791 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0FB399F2B8 for ; Wed, 23 Oct 2013 01:45:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6BA2A203AF for ; Wed, 23 Oct 2013 01:45:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7499203AE for ; Wed, 23 Oct 2013 01:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753655Ab3JWBo6 (ORCPT ); Tue, 22 Oct 2013 21:44:58 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44493 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753511Ab3JWBo6 (ORCPT ); Tue, 22 Oct 2013 21:44:58 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A3D5BA5879; Wed, 23 Oct 2013 03:44:56 +0200 (CEST) Date: Wed, 23 Oct 2013 12:44:44 +1100 From: NeilBrown To: tasleson@redhat.com Cc: linux-nfs@vger.kernel.org, Steve Dickson Subject: Re: [PATCH] exportfs: Return non-zero exit value on error Message-ID: <20131023124444.65ace6e3@notabene.brown> In-Reply-To: <52669862.6030409@redhat.com> References: <1380756584-13335-1-git-send-email-tasleson@redhat.com> <20131022092519.4f4683a8@notabene.brown> <52669862.6030409@redhat.com> X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.18; x86_64-suse-linux-gnu) Mime-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_TVD_MIME_EPI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 22 Oct 2013 10:23:14 -0500 Tony Asleson wrote: > On 10/21/2013 05:25 PM, NeilBrown wrote: > > On Wed, 2 Oct 2013 18:29:44 -0500 Tony Asleson 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 > > > > 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); }