From patchwork Mon Jan 19 07:27:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fan Chengniang X-Patchwork-Id: 5655141 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8E128C058D for ; Mon, 19 Jan 2015 07:30:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BADEC20351 for ; Mon, 19 Jan 2015 07:30:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D98032014A for ; Mon, 19 Jan 2015 07:30:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751185AbbASH3D (ORCPT ); Mon, 19 Jan 2015 02:29:03 -0500 Received: from cn.fujitsu.com ([59.151.112.132]:37807 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751164AbbASH3B (ORCPT ); Mon, 19 Jan 2015 02:29:01 -0500 X-IronPort-AV: E=Sophos;i="5.04,848,1406563200"; d="scan'208";a="56255516" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 19 Jan 2015 15:24:59 +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 t0J7Ro79025188; Mon, 19 Jan 2015 15:27:50 +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; Mon, 19 Jan 2015 15:28:30 +0800 From: Fan Chengniang To: CC: , Fan Chengniang Subject: [PATCH v2 2/2] btrfs-progs:btrfstune:fix multiple options error Date: Mon, 19 Jan 2015 15:27:31 +0800 Message-ID: <1421652451-994-2-git-send-email-fancn.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421652451-994-1-git-send-email-fancn.fnst@cn.fujitsu.com> References: <1421652451-994-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 15f68c8..075fbc6 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -114,6 +114,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; @@ -190,19 +191,22 @@ int main(int argc, char *argv[]) ret = update_seeding_flag(root, seeding_value); 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;