Blame SOURCES/autofs-5.1.2-add-master-read-wait-option.patch

23b4c9
autofs-5.1.2 - add master read wait option
23b4c9
23b4c9
From: Ian Kent <raven@themaw.net>
23b4c9
23b4c9
Add command line and configuration options to set the amount of time to
23b4c9
wait for the master map to become available at program start.
23b4c9
23b4c9
Signed-off-by: Ian Kent <raven@themaw.net>
23b4c9
---
23b4c9
 CHANGELOG                      |    1 +
23b4c9
 daemon/automount.c             |   11 +++++++++--
23b4c9
 include/defaults.h             |    2 ++
23b4c9
 lib/defaults.c                 |   17 +++++++++++++++++
23b4c9
 man/autofs.conf.5.in           |    5 +++++
23b4c9
 man/automount.8                |    4 ++++
23b4c9
 redhat/autofs.conf.default.in  |    7 +++++++
23b4c9
 samples/autofs.conf.default.in |    7 +++++++
23b4c9
 8 files changed, 52 insertions(+), 2 deletions(-)
23b4c9
23b4c9
--- autofs-5.0.7.orig/CHANGELOG
23b4c9
+++ autofs-5.0.7/CHANGELOG
23b4c9
@@ -207,6 +207,7 @@
23b4c9
 - fix use-after-free in st_queue_handler().
23b4c9
 - add config option to supress not found log message.
23b4c9
 - wait for master map available at start.
23b4c9
+- add master read wait option.
23b4c9
 
23b4c9
 25/07/2012 autofs-5.0.7
23b4c9
 =======================
23b4c9
--- autofs-5.0.7.orig/daemon/automount.c
23b4c9
+++ autofs-5.0.7/daemon/automount.c
23b4c9
@@ -2082,10 +2082,11 @@ int main(int argc, char *argv[])
23b4c9
 	unsigned ghost, logging, daemon_check;
23b4c9
 	unsigned dumpmaps, foreground, have_global_options;
23b4c9
 	unsigned master_read;
23b4c9
+	int master_wait;
23b4c9
 	time_t timeout;
23b4c9
 	time_t age = time(NULL);
23b4c9
 	struct rlimit rlim;
23b4c9
-	const char *options = "+hp:t:vmdD:fVrO:l:n:CF";
23b4c9
+	const char *options = "+hp:t:vmdD:fVrO:l:n:CFM";
23b4c9
 	static const struct option long_options[] = {
23b4c9
 		{"help", 0, 0, 'h'},
23b4c9
 		{"pid-file", 1, 0, 'p'},
23b4c9
@@ -2102,6 +2103,7 @@ int main(int argc, char *argv[])
23b4c9
 		{"set-log-priority", 1, 0, 'l'},
23b4c9
 		{"dont-check-daemon", 0, 0, 'C'},
23b4c9
 		{"force", 0, 0, 'F'},
23b4c9
+		{"master-wait", 1, 0, 'M'},
23b4c9
 		{0, 0, 0, 0}
23b4c9
 	};
23b4c9
 
23b4c9
@@ -2122,6 +2124,7 @@ int main(int argc, char *argv[])
23b4c9
 	nfs_mount_uses_string_options = check_nfs_mount_version(&vers, &check);
23b4c9
 
23b4c9
 	kpkt_len = get_kpkt_len();
23b4c9
+	master_wait = defaults_get_master_wait();
23b4c9
 	timeout = defaults_get_timeout();
23b4c9
 	ghost = defaults_get_browse_mode();
23b4c9
 	logging = defaults_get_logging();
23b4c9
@@ -2181,6 +2184,10 @@ int main(int argc, char *argv[])
23b4c9
 			dumpmaps = 1;
23b4c9
 			break;
23b4c9
 
23b4c9
+		case 'M':
23b4c9
+			master_wait = getnumopt(optarg, opt);
23b4c9
+			break;
23b4c9
+
23b4c9
 		case 'O':
23b4c9
 			if (!have_global_options) {
23b4c9
 				global_options = strdup(optarg);
23b4c9
@@ -2502,7 +2509,7 @@ int main(int argc, char *argv[])
23b4c9
 		 * a signal is received, in which case exit returning an
23b4c9
 		 * error.
23b4c9
 		 */
23b4c9
-		if (!do_master_read_master(master_list, -1)) {
23b4c9
+		if (!do_master_read_master(master_list, master_wait)) {
23b4c9
 			logerr("%s: failed to read master map!", program);
23b4c9
 			master_kill(master_list);
23b4c9
 			release_flag_file();
23b4c9
--- autofs-5.0.7.orig/include/defaults.h
23b4c9
+++ autofs-5.0.7/include/defaults.h
23b4c9
@@ -25,6 +25,7 @@
23b4c9
 #define DEFAULT_MASTER_MAP_NAME	"auto.master"
23b4c9
 
23b4c9
 #define DEFAULT_TIMEOUT			"600"
23b4c9
+#define DEFAULT_MASTER_WAIT		"-1"
23b4c9
 #define DEFAULT_NEGATIVE_TIMEOUT	"60"
23b4c9
 #define DEFAULT_MOUNT_WAIT		"-1"
23b4c9
 #define DEFAULT_UMOUNT_WAIT		"12"
23b4c9
@@ -152,6 +153,7 @@ void defaults_conf_release(void);
23b4c9
 const char *defaults_get_master_map(void);
23b4c9
 int defaults_master_set(void);
23b4c9
 unsigned int defaults_get_timeout(void);
23b4c9
+int defaults_get_master_wait(void);
23b4c9
 unsigned int defaults_get_negative_timeout(void);
23b4c9
 unsigned int defaults_get_browse_mode(void);
23b4c9
 unsigned int defaults_get_logging(void);
23b4c9
--- autofs-5.0.7.orig/lib/defaults.c
23b4c9
+++ autofs-5.0.7/lib/defaults.c
23b4c9
@@ -47,6 +47,7 @@
23b4c9
 #define NAME_MASTER_MAP			"master_map_name"
23b4c9
 
23b4c9
 #define NAME_TIMEOUT			"timeout"
23b4c9
+#define NAME_MASTER_WAIT		"master_wait"
23b4c9
 #define NAME_NEGATIVE_TIMEOUT		"negative_timeout"
23b4c9
 #define NAME_BROWSE_MODE		"browse_mode"
23b4c9
 #define NAME_LOGGING			"logging"
23b4c9
@@ -287,6 +288,11 @@ static int conf_load_autofs_defaults(voi
23b4c9
 	if (ret == CFG_FAIL)
23b4c9
 		goto error;
23b4c9
 
23b4c9
+	ret = conf_update(sec, NAME_MASTER_WAIT,
23b4c9
+			  DEFAULT_MASTER_WAIT, CONF_ENV);
23b4c9
+	if (ret == CFG_FAIL)
23b4c9
+		goto error;
23b4c9
+
23b4c9
 	ret = conf_update(sec, NAME_NEGATIVE_TIMEOUT,
23b4c9
 			  DEFAULT_NEGATIVE_TIMEOUT, CONF_ENV);
23b4c9
 	if (ret == CFG_FAIL)
23b4c9
@@ -1568,6 +1574,17 @@ unsigned int defaults_get_timeout(void)
23b4c9
 	return (unsigned int) timeout;
23b4c9
 }
23b4c9
 
23b4c9
+int defaults_get_master_wait(void)
23b4c9
+{
23b4c9
+	long wait;
23b4c9
+
23b4c9
+	wait = conf_get_number(autofs_gbl_sec, NAME_MASTER_WAIT);
23b4c9
+	if (wait < 0)
23b4c9
+		wait = atol(DEFAULT_MASTER_WAIT);
23b4c9
+
23b4c9
+	return (int) wait;
23b4c9
+}
23b4c9
+
23b4c9
 unsigned int defaults_get_negative_timeout(void)
23b4c9
 {
23b4c9
 	long n_timeout;
23b4c9
--- autofs-5.0.7.orig/man/autofs.conf.5.in
23b4c9
+++ autofs-5.0.7/man/autofs.conf.5.in
23b4c9
@@ -30,6 +30,11 @@ default is 10 minutes, but the default i
23b4c9
 overrides this and sets the timeout to 5 minutes to be consistent
23b4c9
 with earlier autofs releases.
23b4c9
 .TP
23b4c9
+.B master_wait
23b4c9
+sets the default maximum time to wait for the master map to become
23b4c9
+available if it cannot be read at program start (program default -1,
23b4c9
+wait forever).
23b4c9
+.TP
23b4c9
 .B negative_timeout
23b4c9
 .br
23b4c9
 Set the default timeout for caching failed key lookups (program default
23b4c9
--- autofs-5.0.7.orig/man/automount.8
23b4c9
+++ autofs-5.0.7/man/automount.8
23b4c9
@@ -37,6 +37,10 @@ The internal program default is 10 minut
23b4c9
 installed configuration overrides this and sets the timeout
23b4c9
 to 5 minutes to be consistent with earlier autofs releases.
23b4c9
 .TP
23b4c9
+.I "\-M <seconds>, \-\-master-wait <seconds>"
23b4c9
+Set the maximum time to wait for the master map to become available
23b4c9
+if it cannot be read at program start.
23b4c9
+.TP
23b4c9
 .I "\-n <seconds>, \-\-negative\-timeout <seconds>"
23b4c9
 Set the default timeout for caching failed key lookups. The default is 60 seconds.
23b4c9
 .TP
23b4c9
--- autofs-5.0.7.orig/redhat/autofs.conf.default.in
23b4c9
+++ autofs-5.0.7/redhat/autofs.conf.default.in
23b4c9
@@ -14,6 +14,13 @@
23b4c9
 #
23b4c9
 timeout = 300
23b4c9
 #
23b4c9
+# master_wait - set the default maximum time to wait for the
23b4c9
+# 		master map to become available if it cannot
23b4c9
+# 		be read at program start (default -1, wait
23b4c9
+# 		forever).
23b4c9
+#
23b4c9
+#master_wait = -1
23b4c9
+#
23b4c9
 # negative_timeout - set the default negative timeout for
23b4c9
 # 		     failed mount attempts (default 60).
23b4c9
 #
23b4c9
--- autofs-5.0.7.orig/samples/autofs.conf.default.in
23b4c9
+++ autofs-5.0.7/samples/autofs.conf.default.in
23b4c9
@@ -14,6 +14,13 @@
23b4c9
 #
23b4c9
 timeout = 300
23b4c9
 #
23b4c9
+# master_wait - set the default maximum time to wait for the
23b4c9
+# 		master map to become available if it cannot
23b4c9
+# 		be read at program start (default -1, wait
23b4c9
+# 		forever).
23b4c9
+#
23b4c9
+# master_wait = -1
23b4c9
+#
23b4c9
 # negative_timeout - set the default negative timeout for
23b4c9
 # 		     failed mount attempts (default 60).
23b4c9
 #