public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nfs-utils: Allow setting of commented out values in nfs.conf
@ 2018-10-25 15:07 Justin Mitchell
  2018-11-29 19:47 ` Steve Dickson
  0 siblings, 1 reply; 2+ messages in thread
From: Justin Mitchell @ 2018-10-25 15:07 UTC (permalink / raw)
  To: Linux NFS Mailing list; +Cc: Steve Dickson

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@redhat.com>
---
 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;
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfs-utils: Allow setting of commented out values in nfs.conf
  2018-10-25 15:07 [PATCH] nfs-utils: Allow setting of commented out values in nfs.conf Justin Mitchell
@ 2018-11-29 19:47 ` Steve Dickson
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2018-11-29 19:47 UTC (permalink / raw)
  To: Justin Mitchell, Linux NFS Mailing list



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@redhat.com>
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;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-29 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-25 15:07 [PATCH] nfs-utils: Allow setting of commented out values in nfs.conf Justin Mitchell
2018-11-29 19:47 ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox