From patchwork Tue Aug 16 17:21:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9284307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB570600CB for ; Tue, 16 Aug 2016 17:24:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC7E1285E3 for ; Tue, 16 Aug 2016 17:24:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C180A287E0; Tue, 16 Aug 2016 17:24:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6EAD3285E3 for ; Tue, 16 Aug 2016 17:24:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 66E9F1A1E11; Tue, 16 Aug 2016 10:24:09 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ml01.01.org (Postfix) with ESMTP id 9395D1A1E21 for ; Tue, 16 Aug 2016 10:24:07 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 16 Aug 2016 10:24:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,529,1464678000"; d="scan'208";a="866420400" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by orsmga003.jf.intel.com with ESMTP; 16 Aug 2016 10:24:07 -0700 Subject: [ndctl PATCH 3/8] libdaxctl: add daxctl_region_get_seed() From: Dan Williams To: linux-nvdimm@lists.01.org Date: Tue, 16 Aug 2016 10:21:44 -0700 Message-ID: <147136810416.27902.14672512795204206789.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <147136808681.27902.14029119240021638000.stgit@dwillia2-desk3.amr.corp.intel.com> References: <147136808681.27902.14029119240021638000.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Retrieve the device-dax seed, next device-dax instance to configure for the dax_region. Signed-off-by: Dan Williams --- daxctl/lib/libdaxctl.c | 24 ++++++++++++++++++++++++ daxctl/lib/libdaxctl.sym | 1 + daxctl/libdaxctl.h | 1 + 3 files changed, 26 insertions(+) diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c index 4f6bbc0cd7a6..ecdb99640115 100644 --- a/daxctl/lib/libdaxctl.c +++ b/daxctl/lib/libdaxctl.c @@ -327,6 +327,30 @@ DAXCTL_EXPORT unsigned long long daxctl_region_get_available_size( return 0; } +DAXCTL_EXPORT struct daxctl_dev *daxctl_region_get_dev_seed( + struct daxctl_region *region) +{ + struct daxctl_ctx *ctx = daxctl_region_get_ctx(region); + char *path = region->region_buf; + int len = region->buf_len; + char buf[SYSFS_ATTR_SIZE]; + struct daxctl_dev *dev; + + if (snprintf(path, len, "%s/dax_region/seed", region->region_path) >= len) { + err(ctx, "%s: buffer too small!\n", + daxctl_region_get_devname(region)); + return NULL; + } + + if (sysfs_read_attr(ctx, path, buf) < 0) + return NULL; + + daxctl_dev_foreach(region, dev) + if (strcmp(buf, daxctl_dev_get_devname(dev)) == 0) + return dev; + return NULL; +} + static void dax_devices_init(struct daxctl_region *region) { struct daxctl_ctx *ctx = daxctl_region_get_ctx(region); diff --git a/daxctl/lib/libdaxctl.sym b/daxctl/lib/libdaxctl.sym index 6fb11d8757cf..e74d75bf7847 100644 --- a/daxctl/lib/libdaxctl.sym +++ b/daxctl/lib/libdaxctl.sym @@ -35,4 +35,5 @@ LIBDAXCTL_3 { global: daxctl_region_get_available_size; daxctl_region_get_devname; + daxctl_region_get_dev_seed; } LIBNDCTL_2; diff --git a/daxctl/libdaxctl.h b/daxctl/libdaxctl.h index ada20ee1e9dd..bb7aa363a605 100644 --- a/daxctl/libdaxctl.h +++ b/daxctl/libdaxctl.h @@ -44,6 +44,7 @@ struct daxctl_ctx *daxctl_region_get_ctx(struct daxctl_region *region); unsigned long long daxctl_region_get_available_size( struct daxctl_region *region); const char *daxctl_region_get_devname(struct daxctl_region *region); +struct daxctl_dev *daxctl_region_get_dev_seed(struct daxctl_region *region); struct daxctl_dev; struct daxctl_dev *daxctl_dev_get_first(struct daxctl_region *region);