From patchwork Sat Mar 9 20:31:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Mills X-Patchwork-Id: 2242631 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F1AB4DF2F2 for ; Sat, 9 Mar 2013 21:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751399Ab3CIVIM (ORCPT ); Sat, 9 Mar 2013 16:08:12 -0500 Received: from frost.carfax.org.uk ([85.119.82.111]:52371 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079Ab3CIVIL (ORCPT ); Sat, 9 Mar 2013 16:08:11 -0500 Received: from ruthven.local ([10.73.18.16] helo=ruthven.carfax.org.uk) by frost.carfax.org.uk with esmtp (Exim 4.72) (envelope-from ) id 1UEQQC-0007ms-Rx for linux-btrfs@vger.kernel.org; Sat, 09 Mar 2013 20:31:13 +0000 Received: from [10.0.0.10] (helo=ruthven.carfax.org.uk) by ruthven.carfax.org.uk with esmtp (Exim 4.80) (envelope-from ) id 1UEQQC-0003Hi-EU for linux-btrfs@vger.kernel.org; Sat, 09 Mar 2013 20:31:12 +0000 From: Hugo Mills To: linux-btrfs@vger.kernel.org Subject: [PATCH 3/5] Convert balance filter parser to use common nCmSpP replication-level parser Date: Sat, 9 Mar 2013 20:31:09 +0000 Message-Id: <1362861071-12589-4-git-send-email-hugo@carfax.org.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1362861071-12589-1-git-send-email-hugo@carfax.org.uk> References: <1362861071-12589-1-git-send-email-hugo@carfax.org.uk> X-frost.carfax.org.uk-Spam-Score: 0.0 (/) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Balance filters are the second location which takes user input of replication levels. Update this to use the common parser so that we can provide nCmSpP-style names. Signed-off-by: Hugo Mills --- cmds-balance.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/cmds-balance.c b/cmds-balance.c index f5dc317..6186963 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -42,23 +42,16 @@ static const char balance_cmd_group_info[] = static int parse_one_profile(const char *profile, u64 *flags) { - if (!strcmp(profile, "raid0")) { - *flags |= BTRFS_BLOCK_GROUP_RAID0; - } else if (!strcmp(profile, "raid1")) { - *flags |= BTRFS_BLOCK_GROUP_RAID1; - } else if (!strcmp(profile, "raid10")) { - *flags |= BTRFS_BLOCK_GROUP_RAID10; - } else if (!strcmp(profile, "raid5")) { - *flags |= BTRFS_BLOCK_GROUP_RAID5; - } else if (!strcmp(profile, "raid6")) { - *flags |= BTRFS_BLOCK_GROUP_RAID6; - } else if (!strcmp(profile, "dup")) { - *flags |= BTRFS_BLOCK_GROUP_DUP; - } else if (!strcmp(profile, "single")) { - *flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; - } else { + u64 result; + + result = parse_profile(profile); + if (result == (u64)-1) { fprintf(stderr, "Unknown profile '%s'\n", profile); return 1; + } else if (result == 0) { + *flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; + } else { + *flags |= result; } return 0;