From patchwork Mon May 22 06:51:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249846 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E938C7EE26 for ; Mon, 22 May 2023 06:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232050AbjEVGym (ORCPT ); Mon, 22 May 2023 02:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232126AbjEVGyQ (ORCPT ); Mon, 22 May 2023 02:54:16 -0400 Received: from esa6.hc1455-7.c3s2.iphmx.com (esa6.hc1455-7.c3s2.iphmx.com [68.232.139.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B83FAA1 for ; Sun, 21 May 2023 23:52:01 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="118607963" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="118607963" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa6.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:51:59 +0900 Received: from oym-m2.gw.nic.fujitsu.com (oym-nat-oym-m2.gw.nic.fujitsu.com [192.168.87.59]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id 37A91CD7E4 for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by oym-m2.gw.nic.fujitsu.com (Postfix) with ESMTP id 6AAD8BF4A9 for ; Mon, 22 May 2023 15:51:56 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id C31EC1145B82; Mon, 22 May 2023 15:51:55 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v2 1/6] cxl/monitor: Enable default_log and refactor sanity check Date: Mon, 22 May 2023 14:51:43 +0800 Message-Id: <20230522065148.818977-2-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--14.214300-10.000000 X-TMASE-MatchedRID: MY+gfqSKTkYmIUsxKhH73B1kSRHxj+Z5+gx7Y6zr6DlXPwnnY5XL5K/n cbbeKXJgGch0Pdb2B17LcexyZRDdfKHtbfqnw/DJCKFDk1kJexLRNIyGX0EQxMnJhTYnTng9jcR qQigdY12nsveNgW5ycFeCc7s6V0VH+gtEW3D/QKYgFhzkd+/gE8E5XPQnBzGXq8KsbROd9VQhvk 2mor77msw/xnPT4YLVIAkHRTl/xj3Tyr0pKxS1VwKDWtq/hHcNwRdjnTeqAAGbKItl61J/yZ+in TK0bC9eKrauXd3MZDX4ZcfVYTi075uYg5Ct0VxwxI3Ud3GIUJsWYvASVaWCkRyARZvsalY4 X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org The default_log(/var/log/cxl-monitor.log) should be used when no '-l' argument is specified in daemon mode, but it was not working at all. Here we assigned it a default log per its arguments, and simplify the sanity check so that it can be consistent with the document. Please note that i also removed following addition stuff, since we have added this prefix if needed during parsing the FILENAME in parse_options_prefix(). if (strncmp(monitor.log, "./", 2) != 0) fix_filename(prefix, (const char **)&monitor.log); Signed-off-by: Li Zhijian --- V2: exchange order of previous patch1 and patch2 # Alison a few commit log updated Signed-off-by: Li Zhijian --- cxl/monitor.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/cxl/monitor.c b/cxl/monitor.c index e3469b9a4792..c6df2bad3c53 100644 --- a/cxl/monitor.c +++ b/cxl/monitor.c @@ -164,6 +164,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) }; const char *prefix ="./"; int rc = 0, i; + const char *log; argc = parse_options_prefix(argc, argv, prefix, options, u, 0); for (i = 0; i < argc; i++) @@ -171,32 +172,33 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) if (argc) usage_with_options(u, options); + // sanity check + if (monitor.daemon && monitor.log && !strncmp(monitor.log, "./", 2)) { + error("standard or relative path for will not work for daemon mode\n"); + return -EINVAL; + } + log_init(&monitor.ctx, "cxl/monitor", "CXL_MONITOR_LOG"); - monitor.ctx.log_fn = log_standard; + if (monitor.log) + log = monitor.log; + else + log = monitor.daemon ? default_log : "./standard"; if (monitor.verbose) monitor.ctx.log_priority = LOG_DEBUG; else monitor.ctx.log_priority = LOG_INFO; - if (monitor.log) { - if (strncmp(monitor.log, "./", 2) != 0) - fix_filename(prefix, (const char **)&monitor.log); - if (strncmp(monitor.log, "./standard", 10) == 0 && !monitor.daemon) { - monitor.ctx.log_fn = log_standard; - } else { - const char *log = monitor.log; - - if (!monitor.log) - log = default_log; - monitor.log_file = fopen(log, "a+"); - if (!monitor.log_file) { - rc = -errno; - error("open %s failed: %d\n", monitor.log, rc); - goto out; - } - monitor.ctx.log_fn = log_file; + if (strncmp(log, "./standard", 10) == 0) + monitor.ctx.log_fn = log_standard; + else { + monitor.log_file = fopen(log, "a+"); + if (!monitor.log_file) { + rc = -errno; + error("open %s failed: %d\n", log, rc); + goto out; } + monitor.ctx.log_fn = log_file; } if (monitor.daemon) { From patchwork Mon May 22 06:51:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249845 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E387BC7EE2D for ; Mon, 22 May 2023 06:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjEVGym (ORCPT ); Mon, 22 May 2023 02:54:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232047AbjEVGyQ (ORCPT ); Mon, 22 May 2023 02:54:16 -0400 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B95771A6 for ; Sun, 21 May 2023 23:52:01 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="105695680" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="105695680" Received: from unknown (HELO oym-r1.gw.nic.fujitsu.com) ([210.162.30.89]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:51:59 +0900 Received: from oym-m4.gw.nic.fujitsu.com (oym-nat-oym-m4.gw.nic.fujitsu.com [192.168.87.61]) by oym-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id 777DED29E9 for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by oym-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id AFFDAD4C19 for ; Mon, 22 May 2023 15:51:56 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id 1A24D11464CA; Mon, 22 May 2023 15:51:56 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v2 2/6] cxl/monitor: replace monitor.log_file with monitor.ctx.log_file Date: Mon, 22 May 2023 14:51:44 +0800 Message-Id: <20230522065148.818977-3-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--12.638700-10.000000 X-TMASE-MatchedRID: tQw5ef8H/dt4Ydbp7yKeAVhRyidsElYkQR7lWMXPA1uOVdQAiMmbZ441 Yiw6vZQgEr2Q42LcwM8KRuKRI67R4Aw8Nmue9wz38IK7yRWPRNFc8r3LfPzYa6CjQPEjtbB0dqr zSDDO/UQi+t+0AiFaYvL3NxFKQpq1uE+7i0XVHsEMPOZL2X19in607foZgOWyPdIdnoYIUtmjxY yRBa/qJcFwgTvxipFajoczmuoPCq3NWZv7SwlpdX97wrdQ8BTultpwedVA7EX5xDlC0S5GU5K94 ag/IxDf X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Commit ba5825b0b7e0 ("ndctl/monitor: move common logging functions to util/log.c") have replaced monitor.log_file with monitor.ctx.log_file for ndctl-monitor, but for cxl-monitor, it forgot to do such work. So where user specifies its own logfile, a segmentation fault will be trggered like below: # build/cxl/cxl monitor -l ./monitor.log Segmentation fault (core dumped) Fixes: 299f69f974a6 ("cxl/monitor: add a new monitor command for CXL trace events") Signed-off-by: Li Zhijian --- V2: exchange order of previous patch1 and patch2 # Alison a few commit log updated --- cxl/monitor.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cxl/monitor.c b/cxl/monitor.c index c6df2bad3c53..f0e3c4c3f45c 100644 --- a/cxl/monitor.c +++ b/cxl/monitor.c @@ -37,7 +37,6 @@ const char *default_log = "/var/log/cxl-monitor.log"; static struct monitor { const char *log; struct log_ctx ctx; - FILE *log_file; bool human; bool verbose; bool daemon; @@ -192,8 +191,8 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) if (strncmp(log, "./standard", 10) == 0) monitor.ctx.log_fn = log_standard; else { - monitor.log_file = fopen(log, "a+"); - if (!monitor.log_file) { + monitor.ctx.log_file = fopen(log, "a+"); + if (!monitor.ctx.log_file) { rc = -errno; error("open %s failed: %d\n", log, rc); goto out; @@ -212,7 +211,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) rc = monitor_event(ctx); out: - if (monitor.log_file) - fclose(monitor.log_file); + if (monitor.ctx.log_file) + fclose(monitor.ctx.log_file); return rc; } From patchwork Mon May 22 06:51:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249848 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B521CC7EE2F for ; Mon, 22 May 2023 06:54:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231673AbjEVGyo (ORCPT ); Mon, 22 May 2023 02:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232244AbjEVGyS (ORCPT ); Mon, 22 May 2023 02:54:18 -0400 Received: from esa8.hc1455-7.c3s2.iphmx.com (esa8.hc1455-7.c3s2.iphmx.com [139.138.61.253]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 791B610DE for ; Sun, 21 May 2023 23:52:04 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="105543642" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="105543642" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa8.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:52:02 +0900 Received: from oym-m1.gw.nic.fujitsu.com (oym-nat-oym-m1.gw.nic.fujitsu.com [192.168.87.58]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id DB4EECD7E1 for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by oym-m1.gw.nic.fujitsu.com (Postfix) with ESMTP id 210F1D4F5C for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id 669751145B82; Mon, 22 May 2023 15:51:56 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v2 3/6] cxl/monitor: use strcmp to compare the reserved word Date: Mon, 22 May 2023 14:51:45 +0800 Message-Id: <20230522065148.818977-4-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--4.808400-10.000000 X-TMASE-MatchedRID: 5cMIDPsUQeR/s7IOpKdgtx1kSRHxj+Z5RpgtqnD1BD4yiHqxwIX2MWeX mwoqwyphxQTdQMAU4mRZrjNEQuAJgh/Qfe1gmZY9IBYc5Hfv4BPBOVz0Jwcxl6vCrG0TnfVUg9x e4gtUJtrIv3U+D7ZhENwU8VHXGipCHxPMjOKY7A/+HHE8LDNSg8RB0bsfrpPIcSqbxBgG0w7eBg R0j9VYUfwQigB/IQfQ1Bx2kRmXWMSGYZjW7uqX8puwzcSYfG5zSzXAJYi2bOTKH+L+kVEuvO0Zn KZRWS9/2MK+E9GcckZbjBuldNvkMkoq97WSHdFjfupJaud1uZCfRs6uIbkFVw== X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org According to its document, when '-l standard' is specified, log would be output to the stdout. But actually, since it's using strncmp(a, b, 10) to compare the former 10 characters, it will also wrongly treat a filename starting with a substring 'standard' to stdout. For example: $ cxl monitor -l standard.log User is most likely want to save log to ./standard.log instead of stdout. Signed-off-by: Li Zhijian --- V2: commit log updated # Dave --- cxl/monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cxl/monitor.c b/cxl/monitor.c index f0e3c4c3f45c..179646562187 100644 --- a/cxl/monitor.c +++ b/cxl/monitor.c @@ -188,7 +188,7 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) else monitor.ctx.log_priority = LOG_INFO; - if (strncmp(log, "./standard", 10) == 0) + if (strcmp(log, "./standard") == 0) monitor.ctx.log_fn = log_standard; else { monitor.ctx.log_file = fopen(log, "a+"); From patchwork Mon May 22 06:51:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249849 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A3EC77B73 for ; Mon, 22 May 2023 06:54:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbjEVGyp (ORCPT ); Mon, 22 May 2023 02:54:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232245AbjEVGyS (ORCPT ); Mon, 22 May 2023 02:54:18 -0400 Received: from esa9.hc1455-7.c3s2.iphmx.com (esa9.hc1455-7.c3s2.iphmx.com [139.138.36.223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A090410DC for ; Sun, 21 May 2023 23:52:03 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="105695682" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="105695682" Received: from unknown (HELO yto-r4.gw.nic.fujitsu.com) ([218.44.52.220]) by esa9.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:52:00 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r4.gw.nic.fujitsu.com (Postfix) with ESMTP id 3A58BD3EBD for ; Mon, 22 May 2023 15:51:58 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 760EDD3F11 for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id BC60D114601F; Mon, 22 May 2023 15:51:56 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v2 4/6] cxl/monitor: always log started message Date: Mon, 22 May 2023 14:51:46 +0800 Message-Id: <20230522065148.818977-5-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--12.232700-10.000000 X-TMASE-MatchedRID: fqEte1jlzl/mh3qTH3T2BBlxrtI3TxRkTfK5j0EZbyt9hFikHEFf1nER bS7OZpEDwKkZaLNGSWov47gJfywVWSfB+/OOFhyOTuctSpiuWyUUi4Ehat05499RlPzeVuQQE0o 8W+GU3zDOG+e9aAIpHqepbdVIZ/l3HxPMjOKY7A/+HHE8LDNSg8RB0bsfrpPIfiAqrjYtFiRAzV rWwNWPwOq11iEZvCJi7mcbYkc9NgBKL3Fna1bs1X7cGd19dSFd X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org Tell people monitor is starting rather only daemon mode will log this message before. It's a minor fix so that whatever stdout or logfile is specified, people can see a *normal* message. After this patch # cxl monitor cxl monitor started. ^C # cxl monitor -l standard.log ^C # cat standard.log [1684735993.704815571] [818499] cxl monitor started. # cxl monitor --daemon -l /var/log/daemon.log # cat /var/log/daemon.log [1684736075.817150494] [818509] cxl monitor started. Signed-off-by: Li Zhijian --- V2: commit log updated # Dave --- cxl/monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cxl/monitor.c b/cxl/monitor.c index 179646562187..0736483cc50a 100644 --- a/cxl/monitor.c +++ b/cxl/monitor.c @@ -205,8 +205,8 @@ int cmd_monitor(int argc, const char **argv, struct cxl_ctx *ctx) err(&monitor, "daemon start failed\n"); goto out; } - info(&monitor, "cxl monitor daemon started.\n"); } + info(&monitor, "cxl monitor started.\n"); rc = monitor_event(ctx); From patchwork Mon May 22 06:51:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249851 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C33EC77B75 for ; Mon, 22 May 2023 06:55:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232122AbjEVGzn (ORCPT ); Mon, 22 May 2023 02:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbjEVGzN (ORCPT ); Mon, 22 May 2023 02:55:13 -0400 Received: from esa2.hc1455-7.c3s2.iphmx.com (esa2.hc1455-7.c3s2.iphmx.com [207.54.90.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55CF21FCB for ; Sun, 21 May 2023 23:53:08 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="117471415" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="117471415" Received: from unknown (HELO oym-r2.gw.nic.fujitsu.com) ([210.162.30.90]) by esa2.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:52:03 +0900 Received: from oym-m3.gw.nic.fujitsu.com (oym-nat-oym-m3.gw.nic.fujitsu.com [192.168.87.60]) by oym-r2.gw.nic.fujitsu.com (Postfix) with ESMTP id ACEA5CD7E8 for ; Mon, 22 May 2023 15:51:58 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by oym-m3.gw.nic.fujitsu.com (Postfix) with ESMTP id DC8CFD947D for ; Mon, 22 May 2023 15:51:57 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id 2031B11456CA; Mon, 22 May 2023 15:51:57 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian , Dave Jiang Subject: [ndctl PATCH v2 5/6] Documentation/cxl/cxl-monitor.txt: Fix inaccurate description Date: Mon, 22 May 2023 14:51:47 +0800 Message-Id: <20230522065148.818977-6-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--4.632400-10.000000 X-TMASE-MatchedRID: AuCKiGuH5B4hYREeQEM9SU7nLUqYrlslFIuBIWrdOePfUZT83lbkEI/M VY+TBf96aL3qKCUFEDH4O/wkN6cR6ZH0YXYnbGozFEUknJ/kEl5jFT88f69nG/oLR4+zsDTtjoc zmuoPCq29LyQ4JDCFvHvtfn+qRSOv/hWfCcPVmFI4RMKVeGL9ywIImSWafD+p41H+5mLWxCEZTW qHEry1oU0T3u5Cfou4AEVn2YJISkkVwbf5lERMgI/2RRfVn5u4Tcu6aRtCI3BUKpNI+7y1VHsDE gQ63iHZ X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org No syslog is supported by cxl-monitor Reviewed-by: Dave Jiang Signed-off-by: Li Zhijian --- V2: add Reviewed-by tag --- Documentation/cxl/cxl-monitor.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Documentation/cxl/cxl-monitor.txt b/Documentation/cxl/cxl-monitor.txt index 3fc992e4d4d9..c284099f16c3 100644 --- a/Documentation/cxl/cxl-monitor.txt +++ b/Documentation/cxl/cxl-monitor.txt @@ -39,8 +39,7 @@ OPTIONS --log=:: Send log messages to the specified destination. - "": - Send log messages to specified . When fopen() is not able - to open , log messages will be forwarded to syslog. + Send log messages to specified . - "standard": Send messages to standard output. From patchwork Mon May 22 06:51:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 13249847 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CD1AC7EE2E for ; Mon, 22 May 2023 06:54:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232126AbjEVGyn (ORCPT ); Mon, 22 May 2023 02:54:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232132AbjEVGyR (ORCPT ); Mon, 22 May 2023 02:54:17 -0400 Received: from esa10.hc1455-7.c3s2.iphmx.com (esa10.hc1455-7.c3s2.iphmx.com [139.138.36.225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0261B10D7 for ; Sun, 21 May 2023 23:52:02 -0700 (PDT) X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="105181860" X-IronPort-AV: E=Sophos;i="6.00,183,1681138800"; d="scan'208";a="105181860" Received: from unknown (HELO yto-r1.gw.nic.fujitsu.com) ([218.44.52.217]) by esa10.hc1455-7.c3s2.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 May 2023 15:52:00 +0900 Received: from yto-m4.gw.nic.fujitsu.com (yto-nat-yto-m4.gw.nic.fujitsu.com [192.168.83.67]) by yto-r1.gw.nic.fujitsu.com (Postfix) with ESMTP id DC043DB399 for ; Mon, 22 May 2023 15:51:58 +0900 (JST) Received: from kws-ab1.gw.nic.fujitsu.com (kws-ab1.gw.nic.fujitsu.com [192.51.206.11]) by yto-m4.gw.nic.fujitsu.com (Postfix) with ESMTP id 3AC19D3F04 for ; Mon, 22 May 2023 15:51:58 +0900 (JST) Received: from localhost.localdomain (unknown [10.167.226.45]) by kws-ab1.gw.nic.fujitsu.com (Postfix) with ESMTP id 857701145B82; Mon, 22 May 2023 15:51:57 +0900 (JST) From: Li Zhijian To: nvdimm@lists.linux.dev Cc: linux-cxl@vger.kernel.org, Li Zhijian Subject: [ndctl PATCH v2 6/6] ndctl/monitor: use strcmp to compare the reserved word Date: Mon, 22 May 2023 14:51:48 +0800 Message-Id: <20230522065148.818977-7-lizhijian@fujitsu.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230522065148.818977-1-lizhijian@fujitsu.com> References: <20230522065148.818977-1-lizhijian@fujitsu.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-TM-AS-Product-Ver: IMSS-9.1.0.1408-9.0.0.1002-27642.005 X-TM-AS-User-Approved-Sender: Yes X-TMASE-Version: IMSS-9.1.0.1408-9.0.1002-27642.005 X-TMASE-Result: 10--6.270400-10.000000 X-TMASE-MatchedRID: 5cMIDPsUQeR/s7IOpKdgtx1kSRHxj+Z5RpgtqnD1BD4yiHqxwIX2MWeX mwoqwyphxQTdQMAU4mRZrjNEQuAJgh/Qfe1gmZY9IBYc5Hfv4BPBOVz0Jwcxl6vCrG0TnfVU2d8 mtRIRsUMfM4ErvgcIi9wU8VHXGipCHxPMjOKY7A+u65UDD0aDgsRB0bsfrpPIfiAqrjYtFiSx/9 vUDvOCOmlRG1njmJZzyf/EPDnEuQ0UAG/EuUqq1X7cGd19dSFd X-TMASE-SNAP-Result: 1.821001.0001-0-1-22:0,33:0,34:0-0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org According to its document, when '-l standard' is specified, log would be output to the stdout. But actually, since it's using strncmp(a, b, 10) to compare the former 10 characters, it will also wrongly treat a filename starting with a substring 'standard' to stdout. For example: $ ndctl monitor -l standard.log User is most likely want to save log to ./standard.log instead of stdout. Signed-off-by: Li Zhijian --- V2: commit log updated # Dave --- ndctl/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndctl/monitor.c b/ndctl/monitor.c index 89903def63d4..bd8a74863476 100644 --- a/ndctl/monitor.c +++ b/ndctl/monitor.c @@ -610,9 +610,9 @@ int cmd_monitor(int argc, const char **argv, struct ndctl_ctx *ctx) if (monitor.log) { if (strncmp(monitor.log, "./", 2) != 0) fix_filename(prefix, (const char **)&monitor.log); - if (strncmp(monitor.log, "./syslog", 8) == 0) + if (strcmp(monitor.log, "./syslog") == 0) monitor.ctx.log_fn = log_syslog; - else if (strncmp(monitor.log, "./standard", 10) == 0) + else if (strcmp(monitor.log, "./standard") == 0) monitor.ctx.log_fn = log_standard; else { monitor.ctx.log_file = fopen(monitor.log, "a+");