Re: [PATCH] nfs-utils: Allow setting of commented out values in nfs.conf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/25/18 11:07 AM, Justin Mitchell wrote:
> When using nfsconf tool to set values, allow it to uncomment a setting
> it finds in the relevant section if it would otherwise have had to create
> a new one.
> 
> Signed-off-by: Justin Mitchell <jumitche@xxxxxxxxxx>
Committed... Sorry it too so long.... 

steved.

> ---
>  support/nfs/conffile.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
> index 3845b94..713f81b 100644
> --- a/support/nfs/conffile.c
> +++ b/support/nfs/conffile.c
> @@ -1830,6 +1830,8 @@ conf_write(const char *filename, const char *section, const char *arg,
>  
>  			/* this is the section we care about */
>  			if (where != NULL && is_section(where->text, section, arg)) {
> +				struct outbuffer *section_start = where;
> +
>  				/* is there an existing assignment */
>  				while ((where = TAILQ_NEXT(where, link)) != NULL) {
>  					if (is_tag(where->text, tag)) {
> @@ -1838,6 +1840,26 @@ conf_write(const char *filename, const char *section, const char *arg,
>  					}
>  				}
>  
> +				/* no active assignment, but is there a commented one */
> +				if (!found) {
> +					where = section_start;
> +					while ((where = TAILQ_NEXT(where, link)) != NULL) {
> +						if (is_comment(where->text)) {
> +							char *cline = where->text;
> +							while (isspace(*cline)) cline++;
> +
> +							if (*cline != '#') continue;
> +							cline++;
> +
> +							if (is_tag(cline, tag)) {
> +								found = true;
> +								break;
> +							}
> +						}
> +					}
> +				}
> +
> +				/* replace the located tag with an updated one */
>  				if (found) {
>  					struct outbuffer *prev = TAILQ_PREV(where, tailhead, link);
>  					bool again = false;
> 



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux