Linux-NFS Archive on
 help / color / Atom feed
From: NeilBrown <>
To: Steve Dickson <>
Subject: [PATCH 2/3] conffile: allow optional include files.
Date: Mon, 23 Sep 2019 14:26:58 +1000
Message-ID: <156921281807.27519.17127755754207047423.stgit@noble.brown> (raw)
In-Reply-To: <156921267783.27519.2402857390317412450.stgit@noble.brown>

If nfs.conf contains, for example
  include = /etc/nfs.conf.local
and /etc/nfs.conf.local doesn't exist, then a warning is given.
Sometimes it is useful to have an optional include file which is
included if present, but for which an absence doesn't give a

Systemd has a convention that a hyphen at the start of
an include file name marks it as optional, so add this convention
to nfs-utils.
  include = -/etc/nfs.conf.local
will not give a warning if the file doesn't exist.

Signed-off-by: NeilBrown <>
 support/nfs/conffile.c |   13 ++++++++++---
 systemd/   |    3 +++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 6ba8a35ce7c6..d55bfe10120a 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -412,11 +412,18 @@ conf_parse_line(int trans, char *line, const char *filename, int lineno, char **
 	if (strcasecmp(line, "include")==0) {
 		/* load and parse subordinate config files */
+		_Bool optional = false;
+		if (val && *val == '-') {
+			optional = true;
+			val++;
+		}
 		relpath = relative_path(filename, val);
 		if (relpath == NULL) {
-			xlog_warn("config error at %s:%d: "
-				"error loading included config",
-				  filename, lineno);
+			if (!optional)
+				xlog_warn("config error at %s:%d: error loading included config",
+					  filename, lineno);
diff --git a/systemd/ b/systemd/
index d375bcc1d5a7..3f1c7261991d 100644
--- a/systemd/
+++ b/systemd/
@@ -65,6 +65,9 @@ section headers, then new sections will be created just as if the
 included file appeared in place of the
 .B include
+If the file name starts with a hyphen then that is stripped off
+before the file is opened, and if file doesn't exist no warning is
+given.  Normally a non-existent include file generates a warning.
 Lookup of section and value names is case-insensitive.

  parent reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-23  4:26 [PATCH 0/3] some nfs-utils patches NeilBrown
2019-09-23  4:26 ` [PATCH 3/3] statd: take user-id from /var/lib/nfs/sm NeilBrown
2019-09-23  4:26 ` NeilBrown [this message]
2019-09-23  4:26 ` [PATCH 1/3] mountd: Initialize logging early NeilBrown
2019-10-14 18:16 ` [PATCH 0/3] some nfs-utils patches Steve Dickson
2019-10-14 22:36   ` NeilBrown

Reply instructions:

You may reply publically 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:

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

  git send-email \
    --in-reply-to=156921281807.27519.17127755754207047423.stgit@noble.brown \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NFS Archive on

Archives are clonable:
	git clone --mirror linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ \
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone