From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5609C433F5 for ; Mon, 18 Oct 2021 03:49:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BF7660F9E for ; Mon, 18 Oct 2021 03:49:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BF7660F9E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FjEuIca+td3NWlezRBngCTmtKysnToIT2o7LM1Mccp8=; b=YwRA0VqEjHTfYwUZ9aLDvspN1j t8W7sBuXooNBm0mwI37bTnPQIums0MEmSgv4mP4OnHpII+oMvT+kGETbOLQQ34rDJ775jhaOAuGKV +gfHFjo41Os8tPbvg258mFrXxnFuhuMx0B4saVNj8N8Sfq54CZ69H1zq27nJ4W4zOwnoiylsSrZtC 00C8k7bygrXCKltZ5FX/TOIXrPZkVb1diFO+zCkhGXqtIc6NT7O26xWHZaEbbTce1KyuvitFzGF1T D7six10IKDvKhIDfIRjW9zckuO4Y1zKI/bFfj4AIJITeQroeMeNeq3xS6trMIo/Z6VykuYCKLAxJ9 wyIsD+ew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcJef-00DwXI-AF; Mon, 18 Oct 2021 03:49:41 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mcJeb-00DwVu-6t for linux-nvme@lists.infradead.org; Mon, 18 Oct 2021 03:49:39 +0000 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4HXjWM5WL0zWmjn; Mon, 18 Oct 2021 11:47:43 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 11:49:27 +0800 Received: from [10.169.63.14] (10.169.63.14) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 11:49:27 +0800 Message-ID: Date: Mon, 18 Oct 2021 11:49:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.0 Subject: Re: [PATCH nvme-cli] huawei: filter out the partition disks To: , CC: , References: <20211014091130.2083-1-chengjike.cheng@huawei.com> From: "Chengjike (ISSP)" In-Reply-To: <20211014091130.2083-1-chengjike.cheng@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.169.63.14] X-ClientProxiedBy: dggeme701-chm.china.huawei.com (10.1.199.97) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211017_204937_460702_C7A36991 X-CRM114-Status: GOOD ( 11.79 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org ping 在 2021/10/14 17:11, chengjike 写道: > When using "nvme huawei list" command, if the current disk has partitions, > disk partitions will be displayed. This is not expected! > So filter out the disk partitions through disk name. > > Signed-off-by: chengjike > --- > plugins/huawei/huawei-nvme.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/plugins/huawei/huawei-nvme.c b/plugins/huawei/huawei-nvme.c > index 679578f..96de335 100644 > --- a/plugins/huawei/huawei-nvme.c > +++ b/plugins/huawei/huawei-nvme.c > @@ -296,6 +296,8 @@ static int huawei_list(int argc, char **argv, struct command *command, > unsigned int i, n, fd, ret; > unsigned int huawei_num = 0; > int fmt; > + int ctrl, ns, part; > + > const char *desc = "Retrieve basic information for the given huawei device"; > struct config { > char *output_format; > @@ -326,6 +328,8 @@ static int huawei_list(int argc, char **argv, struct command *command, > } > > for (i = 0; i < n; i++) { > + if (sscanf(devices[i]->d_name, "nvme%dn%dp%d", &ctrl, &ns, &part) == 3) > + continue; > snprintf(path, sizeof(path), "/dev/%s", devices[i]->d_name); > fd = open(path, O_RDONLY); > ret = huawei_get_nvme_info(fd, &list_items[huawei_num], path);