From patchwork Thu Jan 23 15:05:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonthan Brassow X-Patchwork-Id: 3532711 Return-Path: X-Original-To: patchwork-dm-devel@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 DCA1B9F39B for ; Fri, 24 Jan 2014 01:59:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 215DE2016C for ; Fri, 24 Jan 2014 01:59:58 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 36A862011D for ; Fri, 24 Jan 2014 01:59:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0O1uc17010571; Thu, 23 Jan 2014 20:56:39 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0O1tVsQ031763 for ; Thu, 23 Jan 2014 20:55:31 -0500 Received: from localhost (vpn-58-140.rdu2.redhat.com [10.10.58.140]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0O1tUdF016424 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 23 Jan 2014 20:55:31 -0500 From: Jonathan Brassow To: dm-devel@redhat.com Date: Thu, 23 Jan 2014 09:05:45 -0600 Message-Id: <1390489548-18076-2-git-send-email-jbrassow@redhat.com> In-Reply-To: <1390489548-18076-1-git-send-email-jbrassow@redhat.com> References: <1390489548-18076-1-git-send-email-jbrassow@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-loop: dm-devel@redhat.com Cc: agk@redhat.com, zkabelac@redhat.com Subject: [dm-devel] [LVM PATCH 1/4] Misc: New function for reading lvm config file, 'dm_config_get_int' X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_06_12, RCVD_IN_DNSWL_HI, 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 --- libdm/libdevmapper.h | 1 + libdm/libdm-config.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index adfbb76..3bf8bd6 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -1661,6 +1661,7 @@ int dm_config_tree_find_bool(const struct dm_config_tree *cft, const char *path, int dm_config_find_bool(const struct dm_config_node *cn, const char *path, int fail); int dm_config_value_is_bool(const struct dm_config_value *v); +int dm_config_get_int(const struct dm_config_node *cn, const char *path, int *result); int dm_config_get_uint32(const struct dm_config_node *cn, const char *path, uint32_t *result); int dm_config_get_uint64(const struct dm_config_node *cn, const char *path, uint64_t *result); int dm_config_get_str(const struct dm_config_node *cn, const char *path, const char **result); diff --git a/libdm/libdm-config.c b/libdm/libdm-config.c index ea1af2f..3297621 100644 --- a/libdm/libdm-config.c +++ b/libdm/libdm-config.c @@ -1047,6 +1047,20 @@ int dm_config_tree_find_bool(const struct dm_config_tree *cft, const char *path, /************************************/ +int dm_config_get_int(const struct dm_config_node *cn, const char *path, + int *result) +{ + const struct dm_config_node *n; + + n = _find_config_node(cn, path); + + if (!n || !n->v || n->v->type != DM_CFG_INT) + return 0; + + if (result) + *result = n->v->v.i; + return 1; +} int dm_config_get_uint32(const struct dm_config_node *cn, const char *path, uint32_t *result)