monitor: removing the requirement of default config
PATCH 1/1 monitor: removing the requirement of default config
Removing the requirement of default configuration file.
If "-c, --config-file" option is not specified, default configuration file should be dispensable.
--- ndctl/monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
ndctl/monitor.c +5 -2
@@ -484,8 +484,11 @@ static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor, f =fopen (config_file,"r" );if (!f) { -err (&monitor,"config-file: %s cannot be opened\n" , config_file); - rc = -errno; +if (_monitor->config_file) { +err (&monitor,"config-file: %s cannot be opened\n" , + config_file); + rc = -errno; + } goto out; }
Signature · 6 lines
2.21.0.rc1 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 19 lines · QI Fuli
Removing the requirement of default configuration file.
If "-c, --config-file" option is not specified, default configuration file should be dispensable.Signed-off-by QI Fuli <[email protected]>--- ndctl/monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)ndctl/monitor.c +0
-0@@ -484,8 +484,11 @@ static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor, f =fopen (config_file,"r" );if (!f) {
ndctl/monitor.c static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor, · line 494
Quoted 10 lines
ndctl/monitor.c +5
-2-err (&monitor,"config-file: %s cannot be opened\n" , config_file); - rc = -errno; +if (_monitor->config_file) { +err (&monitor,"config-file: %s cannot be opened\n" , + config_file); + rc = -errno; + } goto out; }
Hi Qi,
Thanks for the quick patch. However, this makes it so that the only way in which a config file gets used is by explicitly specifying it with a -c option, and that kind of makes a 'default' config file pointless..
The ideal scenario would be:
1. Check if default config exists
a. if it does, use options from there
b. if any cli options provided, use those to override the ones in
config file (if any)
2. If default config file is missing, only use cli options
3. If -c <file> provided, use that, but perform the same treatment as 1b above, i.e. any cli options override anything in the config file from -c as well.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Quoted 55 lines
-----Original Message-----
From: Verma, Vishal L [mailto:[email protected]]
Sent: Saturday, March 30, 2019 2:37 AM
To: [email protected]; Qi, Fuli/斉 福利 <[email protected]>
Subject: Re: [ndctl PATCH] monitor: removing the requirement of default configndctl/monitor.c static int read_config_file(struct ndctl_ctx *ctx,
Quoted 16 lines · QI Fuli
Removing the requirement of default configuration file.
If "-c, --config-file" option is not specified, default configuration file should be dispensable.Signed-off-by QI Fuli <[email protected]>--- ndctl/monitor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)ndctl/monitor.c +0
-0@@ -484,8 +484,11 @@ static int read_config_file(struct ndctl_ctx *ctx,struct monitor
*_monitor,ndctl/monitor.c static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor,
Quoted 4 lines
ndctl/monitor.c +0
-1f =fopen (config_file,"r" );if (!f) { - err(&monitor, "config-file: %s cannot be opened\n",
config_file);ndctl/monitor.c static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor,
Quoted 3 lines
ndctl/monitor.c +2
-1- rc = -errno; +if (_monitor->config_file) { + err(&monitor, "config-file: %s cannot beopened\n",
ndctl/monitor.c static int read_config_file(struct ndctl_ctx *ctx, struct monitor *_monitor, · line 494
Quoted 6 lines
ndctl/monitor.c +3
-0+ config_file); + rc = -errno; + } goto out; }Hi Qi,
Thanks for the quick patch. However, this makes it so that the only way in which a config file gets used is by explicitly specifying it with a -c option, and that kind of makes a 'default' config file pointless..
The ideal scenario would be:
1. Check if default config exists
a. if it does, use options from there
b. if any cli options provided, use those to override the ones in
config file (if any)
Quoted 7 lines
2. If default config file is missing, only use cli options
3. If -c <file> provided, use that, but perform the same treatment as 1b
above, i.e. any cli options override anything in the config file from -c
as well.
Hi Vishal,
Thanks for your comment.
I think it might be misunderstood.
Current scenario is:
1. Check if "-c <file>" option is provided
a. if it is, make the <file> as config_file
b. if it is not, make default configuration file(/etc/ndctl/monitor.conf) as config_file
2. Try to read options from config_file
a. if config_file cannot be opened, then check if "-c" option is provided
(1) if it is, stop starting monitor (user may make a wrong <file> in "-c" option)
(2) if it is not, finish read_config_file (default configuration file(/etc/ndctl/monitor.conf) is missing)
b. if config_file can be opened successfully, merge the options from config_file with cli options
It is consistent with the ideal scenario as you mentioned.
Thanks,
QI Fuli
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
Verma, Vishal L
maintainerQuoted 16 lines · On Mon, 2019-04-01 at 06:20 +0000, [email protected] wrote:
Hi Vishal,
Thanks for your comment.
I think it might be misunderstood.Current scenario is:
1. Check if "-c <file>" option is provided
a. if it is, make the <file> asconfig_file
b. if it is not, make default configuration file(/etc/ndctl/monitor.conf) asconfig_file
2. Try to read options fromconfig_file
a. ifconfig_filecannot be opened, then check if "-c" option is provided
(1) if it is, stop starting monitor (user may make a wrong <file> in "-c" option)
(2) if it is not, finishread_config_file(default configuration file(/etc/ndctl/monitor.conf) is missing)
b. ifconfig_filecan be opened successfully, merge the options fromconfig_filewith cli options
Quoted 1 line
It is consistent with the ideal scenario as you mentioned.
Hi Qi,
Looking at it in more detail, I see you're right. I've applied the patch - thanks for the explanation.
Quoted 3 lines
Thanks,
QI Fuli
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm