ndctl, monitor: Fix duplicate prefix in monitor.log
PATCH 1/1 ndctl, monitor: Fix duplicate prefix in monitor.log
When a monitor runs with [--log] option, the prefix will be dually added to monitor.log. Therefore, the monitor cannot log the smart notification to syslog. This patch is used to prevent prefix from being dually added to monitor.log.
--- ndctl/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ndctl/monitor.c +2 -1
@@ -614,7 +614,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out;if (monitor.log) { -fix_filename (prefix, (const char **)&monitor.log); +if (strncmp (monitor.log,"./" ,2 ) !=0 ) +fix_filename (prefix, (const char **)&monitor.log);if (strncmp (monitor.log,"./syslog" ,8 ) ==0 )ndctl_set_log_fn ((struct ndctl_ctx *)ctx, log_syslog);else if (strncmp (monitor.log,"./standard" ,10 ) ==0 )
Signature · 7 lines
2.18.0 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Hi QI,
Quoted 16 lines · QI Fuli
When a monitor runs with [--log] option, the prefix will be dually added to monitor.log. Therefore, the monitor cannot log the smart notification to syslog. This patch is used to prevent prefix from being dually added to monitor.log.
Fixes fdf6b6844ccf ("ndctl, monitor: add a new command - monitor")Signed-off-by QI Fuli <[email protected]>--- ndctl/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)ndctl/monitor.c +0
-0
ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 618
Quoted 6 lines
ndctl/monitor.c +2
-1@@ -614,7 +614,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out;if (monitor.log) { -fix_filename (prefix, (const char **)&monitor.log); +if (strncmp (monitor.log,"./" ,2 ) !=0 ) +fix_filename (prefix, (const char **)&monitor.log);
prefix is not needed to 'syslog' and 'standard', so why don't you move the strncmp() before fix_filename(), like as:
@@ -614,13 +619,14 @@ int cmd_monitor(int argc, const char **argv, void *ctx)
goto out;
if (monitor.log) {
- fix_filename(prefix, (const char **)&monitor.log);
if (strncmp(monitor.log, "./syslog", 8) == 0)
ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog);
else if (strncmp(monitor.log, "./standard", 10) == 0)
; /*default, already set */
- else
+ else {
+ fix_filename(prefix, (const char **)&monitor.log);
ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file);
+ }
}
if (monitor.daemon) {Thanks,
Masa
ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 621
Quoted 4 lines
ndctl/monitor.c +0
-0if (strncmp (monitor.log,"./syslog" ,8 ) ==0 )ndctl_set_log_fn ((struct ndctl_ctx *)ctx, log_syslog);else if (strncmp (monitor.log,"./standard" ,10 ) ==0 )
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 54 lines
-----Original Message-----
From: Masayoshi Mizuma [mailto:[email protected]]
Sent: Thursday, August 2, 2018 3:15 AM
To: Qi, Fuli/斉 福利 <[email protected]>; [email protected]
Subject: Re: [ndclt PATCH] ndctl, monitor: Fix duplicate prefix in monitor.logHi QI,
Quoted 16 lines · QI Fuli
When a monitor runs with [--log] option, the prefix will be dually added to monitor.log. Therefore, the monitor cannot log the smart notification to syslog. This patch is used to prevent prefix from being dually added to monitor.log.
Fixes fdf6b6844ccf ("ndctl, monitor: add a new command - monitor")Signed-off-by QI Fuli <[email protected]>--- ndctl/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)ndctl/monitor.c index c6419ad..4e5daf5 renamed from ndctl/monitor.c +0
-0100644
ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 618
Quoted 6 lines
ndctl/monitor.c +2
-1@@ -614,7 +614,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out;if (monitor.log) { -fix_filename (prefix, (const char **)&monitor.log); +if (strncmp (monitor.log,"./" ,2 ) !=0 ) +fix_filename (prefix, (const char **)&monitor.log);prefix is not needed to 'syslog' and 'standard', so why don't you move the
strncmp()beforefix_filename(), like as:(quoted diff) +4
-2@@ -614,13 +619,14 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out; if (monitor.log) { - fix_filename(prefix, (const char **)&monitor.log); if (strncmp(monitor.log, "./syslog", 8) == 0) ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog); else if (strncmp(monitor.log, "./standard", 10) == 0) ; /*default, already set */ - else + else { + fix_filename(prefix, (const char + **)&monitor.log); ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file); + } } if (monitor.daemon) {
Quoted 2 lines
Thanks,
Masa
Hi Masa,
Thank you very much for your comments.
There are two ways to set monitor.log.
a) setting the argument of [--log] option
b) setting the value of [log] key in configuration file
When users set monitor.log by b, the prefix will not be added to monitor.log. Therefore, we should do fix_filename() before strncmp().
Thanks,
QI
Quoted 6 lines
ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 621
Quoted 5 lines
ndctl/monitor.c +0
-0if (strncmp (monitor.log,"./syslog" ,8 ) ==0 )ndctl_set_log_fn ((struct ndctl_ctx *)ctx, log_syslog);else if (strncmp (monitor.log,"./standard" ,10 ) ==0 )
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Masayoshi Mizuma
Reviewed-byHi QI,
On 08/02/2018 05:42 AM, Qi, Fuli wrote:
...
Quoted 39 lines
Quoted 34 lines
ndctl/monitor.c int cmd_monitor(int argc, const char **argv, void *ctx) · line 618
Quoted 11 lines
ndctl/monitor.c index c6419ad..4e5daf5 renamed from ndctl/monitor.c +0
-0100644
ndctl/monitor.c +2
-1@@ -614,7 +614,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out;if (monitor.log) { -fix_filename (prefix, (const char **)&monitor.log); +if (strncmp (monitor.log,"./" ,2 ) !=0 ) +fix_filename (prefix, (const char **)&monitor.log);prefix is not needed to 'syslog' and 'standard', so why don't you move the
strncmp()beforefix_filename(), like as:(quoted diff) +4
-2@@ -614,13 +619,14 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out; if (monitor.log) { - fix_filename(prefix, (const char **)&monitor.log); if (strncmp(monitor.log, "./syslog", 8) == 0) ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog); else if (strncmp(monitor.log, "./standard", 10) == 0) ; /*default, already set */ - else + else { + fix_filename(prefix, (const char + **)&monitor.log); ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_file); + } } if (monitor.daemon) {Quoted 2 lines
Thanks,
MasaHi Masa,
Quoted 8 lines
Thank you very much for your comments.
There are two ways to set monitor.log.
a) setting the argument of [--log] option
b) setting the value of [log] key in configuration fileWhen users set monitor.log by b, the prefix will not be added to monitor.log. Therefore, we should do
fix_filename()beforestrncmp().
Oh, my proposal patch does not cover in case of user set 'syslog' or 'standard'in config_file. I think your patch fixes the bug correctly, thanks.
Please feel free to add:
Thanks,
Masa
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 63 lines · Masayoshi Mizuma
Hi QI,
On 08/02/2018 05:42 AM, Qi, Fuli wrote:
...Quoted 51 lines
Quoted 40 lines
Quoted 6 lines
ndctl/monitor.c index renamed from ndctl/monitor.c +0
-0c6419ad..4e5daf5
100644ndctl/monitor.c int cmd_monitor(int argc, const char · line 621
Quoted 9 lines
ndctl/monitor.c +2
-1@@ -614,7 +614,8 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out;if (monitor.log) { -fix_filename (prefix, (const char **)&monitor.log); +if (strncmp (monitor.log,"./" ,2 ) !=0 ) +fix_filename (prefix, (const char **)&monitor.log);prefix is not needed to 'syslog' and 'standard', so why don't you move the
strncmp()
beforefix_filename(), like as:(quoted diff) +3
-2@@ -614,13 +619,14 @@ int cmd_monitor(int argc, const char **argv, void *ctx) goto out; if (monitor.log) { - fix_filename(prefix, (const char **)&monitor.log); if (strncmp(monitor.log, "./syslog", 8) == 0) ndctl_set_log_fn((struct ndctl_ctx *)ctx, log_syslog); else if (strncmp(monitor.log, "./standard", 10) == 0) ; /*default, already set */ - else + else { + fix_filename(prefix, (const char + **)&monitor.log);ndctl_set_log_fn((struct
ndctl_ctx*)ctx,log_file);
+ }Quoted 6 lines
} if (monitor.daemon) {Thanks,
MasaHi Masa,
Thank you very much for your comments.
Quoted 7 lines
There are two ways to set monitor.log.
a) setting the argument of [--log] option
b) setting the value of [log] key in configuration fileWhen users set monitor.log by b, the prefix will not be added to monitor.log.
Therefore, we should dofix_filename()beforestrncmp().
Quoted 7 lines
Oh, my proposal patch does not cover in case of user set 'syslog' or 'standard'in
config_file.
I think your patch fixes the bug correctly, thanks.Please feel free to add:
Reviewed-by Masayoshi Mizuma <[email protected]>
Thanks Qi, Masa - I've applied this.
Quoted 7 lines
Thanks,
Masa
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm