From patchwork Thu Jan 5 00:15:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9498091 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 8ACA6606B4 for ; Thu, 5 Jan 2017 00:20:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C91328358 for ; Thu, 5 Jan 2017 00:20:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EFA3283AC; Thu, 5 Jan 2017 00:20:07 +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 65FB028358 for ; Thu, 5 Jan 2017 00:20:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2821781959; Wed, 4 Jan 2017 16:20:05 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2ABEE81957 for ; Wed, 4 Jan 2017 16:20:04 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 04 Jan 2017 16:20:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,318,1477983600"; d="scan'208";a="26279627" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by orsmga002.jf.intel.com with ESMTP; 04 Jan 2017 16:20:03 -0800 Subject: [ndctl PATCH] ndctl: support machines without numa From: Dan Williams To: linux-nvdimm@lists.01.org Date: Wed, 04 Jan 2017 16:15:57 -0800 Message-ID: <148357532903.9100.4272827749663933501.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 From: Diego Dompe Currently when using ndctl in machines that do not have numa, the ndctl command fails because it fails to find the numa_node attribute in systems. Just assume the default, zero, in these cases rather than fail. Link: https://github.com/pmem/ndctl/pull/9 [djbw: minor style fixups] Signed-off-by: Dan Williams Reviewed-by: Jeff Moyer --- Diego, if this reworked version looks good to you I'll add your "Signed-off-by: Diego Dompe " to the tags. Let me know. Thanks for the fix! ndctl/lib/libndctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index ea3111eb6c93..8240235dff5c 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -2780,9 +2780,8 @@ static void *add_namespace(void *parent, int id, const char *ndns_base) ndns->raw_mode = strtoul(buf, NULL, 0); sprintf(path, "%s/numa_node", ndns_base); - if (sysfs_read_attr(ctx, path, buf) < 0) - goto err_read; - ndns->numa_node = strtol(buf, NULL, 0); + if (sysfs_read_attr(ctx, path, buf) == 0) + ndns->numa_node = strtol(buf, NULL, 0); switch (ndns->type) { case ND_DEVICE_NAMESPACE_BLK: