public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alice Mitchell <ajmitchell@redhat.com>
To: Steve Dickson <SteveD@RedHat.com>,
	Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: Re: [RFC PATCH 0/1] Enable config.d directory to be processed.
Date: Mon, 02 Nov 2020 15:05:49 +0000	[thread overview]
Message-ID: <a42154ffeb06a21590db01ab651870040597571c.camel@redhat.com> (raw)
In-Reply-To: <4836616f-3aa6-d0bd-22db-cd7fecf4dce9@RedHat.com>

Hi Steve,
That should work yes, although I am still dubious of the merits of
replacing the single config file with multiple ones rather than reading
them in addition to it. Surely this is going to lead to queries of why
the main config file is being ignored just because the directory also
existed.

I also have concerns that blindly loading -every- file in the directory
is also going to lead to problems, such as foo.conf.rpmorig files and
the like.  This is why i suggested a glob would be a better solution

-Alice


On Mon, 2020-11-02 at 09:23 -0500, Steve Dickson wrote:
> Hello,
> 
> On 11/2/20 8:24 AM, Steve Dickson wrote:
> > > You would need to write an equivalent of conf_load_file() that
> > > created
> > > a new transaction id and read in all the files before committing
> > > them
> > > to do it this way.
> > I kinda do think we should be able to read in multiple files...
> > If that free was not done until all the files are read in, would
> > something
> > like that work? I guess I'm ask how difficult would be to re-work
> > the code to do something like this. 
> > 
> Something similar to this... load all the files under the same trans
> id:
> (Compiled tested):
> diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
> index c60e511..f003fe1 100644
> --- a/support/nfs/conffile.c
> +++ b/support/nfs/conffile.c
> @@ -578,6 +578,30 @@ static void conf_free_bindings(void)
>  	}
>  }
>  
> +static int
> +conf_load_files(int trans, const char *conf_file)
> +{
> +	char *conf_data;
> +	char *section = NULL;
> +	char *subsection = NULL;
> +
> +	conf_data = conf_readfile(conf_file);
> +	if (conf_data == NULL)
> +		return 1;
> +
> +	/* Load default configuration values.  */
> +	conf_load_defaults();
> +
> +	/* Parse config contents into the transaction queue */
> +	conf_parse(trans, conf_data, &section, &subsection, conf_file);
> +	if (section) 
> +		free(section);
> +	if (subsection) 
> +		free(subsection);
> +	free(conf_data);
> +
> +	return 0;
> +}
>  /* Open the config file and map it into our address space, then
> parse it.  */
>  static int
>  conf_load_file(const char *conf_file)
> @@ -616,6 +640,7 @@ conf_init_dir(const char *conf_file)
>  	struct dirent **namelist = NULL;
>  	char *dname, fname[PATH_MAX + 1];
>  	int n = 0, nfiles = 0, i, fname_len, dname_len;
> +	int trans;
>  
>  	dname = malloc(strlen(conf_file) + 3);
>  	if (dname == NULL) {
> @@ -637,6 +662,7 @@ conf_init_dir(const char *conf_file)
>  		return nfiles;
>  	}
>  
> +	trans = conf_begin();
>  	dname_len = strlen(dname);
>  	for (i = 0; i < n; i++ ) {
>  		struct dirent *d = namelist[i];
> @@ -660,11 +686,17 @@ conf_init_dir(const char *conf_file)
>  		}
>  		sprintf(fname, "%s/%s", dname, d->d_name);
>  
> -		if (conf_load_file(fname))
> +		if (conf_load_files(trans, fname))
>  			continue;
>  		nfiles++;
>  	}
>  
> +	/* Free potential existing configuration.  */
> +	conf_free_bindings();
> +
> +	/* Apply the new configuration values */
> +	conf_end(trans, 1);
> +
>  	for (i = 0; i < n; i++)
>  		free(namelist[i]);
>  	free(namelist);
> 


  reply	other threads:[~2020-11-02 15:05 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-29 21:04 [RFC PATCH 0/1] Enable config.d directory to be processed Steve Dickson
2020-10-29 21:04 ` [PATCH 1/1] conffile: process config.d directory config files Steve Dickson
2020-11-02 13:03 ` [RFC PATCH 0/1] Enable config.d directory to be processed Alice Mitchell
2020-11-02 13:24   ` Steve Dickson
2020-11-02 14:23     ` Steve Dickson
2020-11-02 15:05       ` Alice Mitchell [this message]
2020-11-02 15:16         ` Chuck Lever
2020-11-02 16:37           ` Steve Dickson
2020-11-02 16:42         ` Steve Dickson
2020-11-02 15:57       ` Alice Mitchell
2020-11-02 19:42         ` Steve Dickson
2020-11-02 22:01           ` McIntyre, Vincent (CASS, Marsfield)
2020-11-03 10:14           ` Alice Mitchell
2020-11-03 17:16             ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a42154ffeb06a21590db01ab651870040597571c.camel@redhat.com \
    --to=ajmitchell@redhat.com \
    --cc=SteveD@RedHat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox