From patchwork Fri Jan 9 08:11:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Chengniang X-Patchwork-Id: 5596891 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F2D459F444 for ; Fri, 9 Jan 2015 08:13:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 294E62050B for ; Fri, 9 Jan 2015 08:13:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38D4420483 for ; Fri, 9 Jan 2015 08:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755009AbbAIIM4 (ORCPT ); Fri, 9 Jan 2015 03:12:56 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:13785 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1754741AbbAIIM4 (ORCPT ); Fri, 9 Jan 2015 03:12:56 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="55803085" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 09 Jan 2015 16:09:30 +0800 Received: from G08CNEXCHPEKD02.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id t098CL52030005 for ; Fri, 9 Jan 2015 16:12:22 +0800 Received: from fan-Lenovo.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD02.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.181.6; Fri, 9 Jan 2015 16:12:55 +0800 From: Fan Chengniang To: CC: Fan Chengniang Subject: [PATCH 2/2] btrfs-progs:btrfstune:fix multiple options error Date: Fri, 9 Jan 2015 16:11:42 +0800 Message-ID: <1420791102-9948-2-git-send-email-fancn.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1420791102-9948-1-git-send-email-fancn.fnst@cn.fujitsu.com> References: <1420791102-9948-1-git-send-email-fancn.fnst@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.45] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 when we use multiple options, error return status will be override by the last option status. example: btrfstune -S 1 -r /dev/loop0 when -S option fails and -r option succeeds, return value is 0, rather than 1, where 1 is the right return status. Reported-by: Chen Hanxiao Signed-off-by: Fan Chengniang --- btrfstune.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/btrfstune.c b/btrfstune.c index 9a9e855..499a71d 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -117,6 +117,7 @@ int main(int argc, char *argv[]) { struct btrfs_root *root; int success = 0; + int total = 0; int extrefs_flag = 0; int seeding_flag = 0; u64 seeding_value = 0; @@ -199,19 +200,22 @@ int main(int argc, char *argv[]) ignore_enabled_seeding); if (!ret) success++; + total++; } if (extrefs_flag) { enable_extrefs_flag(root); success++; + total++; } if (skinny_flag) { enable_skinny_metadata(root); success++; + total++; } - if (success > 0) { + if (success == total) { ret = 0; } else { root->fs_info->readonly = 1;