--- autofs-5.0.1/modules/parse_sun.c.cmd-global-options 2007-05-04 14:26:28.000000000 +0800 +++ autofs-5.0.1/modules/parse_sun.c 2007-05-04 14:27:28.000000000 +0800 @@ -42,6 +42,8 @@ static struct mount_mod *mount_nfs = NULL; static int init_ctr = 0; +extern const char *global_options; + struct parse_context { char *optstr; /* Mount options */ char *macros; /* Map wide macro defines */ @@ -65,6 +67,8 @@ 1 /* Do slashify_colons */ }; +static char *concat_options(char *left, char *right); + /* Free all storage associated with this context */ static void kill_context(struct parse_context *ctxt) { @@ -264,6 +268,7 @@ const char *xopt; int optlen, len, offset; int i, bval; + unsigned int append_options; /* Get processor information for predefined escapes */ @@ -392,6 +397,25 @@ } } + if (global_options) { + append_options = defaults_get_append_options(); + if (append_options) { + char *tmp = concat_options(global_options, ctxt->optstr); + if (!tmp) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + error(LOGOPT_ANY, MODPREFIX "concat_options: %s", estr); + } else + ctxt->optstr = tmp; + } else { + if (!ctxt->optstr) + ctxt->optstr = strdup(global_options); + if (!ctxt->optstr) { + char *estr = strerror_r(errno, buf, MAX_ERR_BUF); + warn(LOGOPT_ANY, MODPREFIX "%s", estr); + } + } + } + debug(LOGOPT_NONE, MODPREFIX "init gathered global options: %s", ctxt->optstr); --- autofs-5.0.1/daemon/automount.c.cmd-global-options 2007-05-04 14:26:28.000000000 +0800 +++ autofs-5.0.1/daemon/automount.c 2007-05-04 14:27:51.000000000 +0800 @@ -46,6 +46,8 @@ const char *mapdir = AUTOFS_MAP_DIR; /* Location of mount maps */ const char *confdir = AUTOFS_CONF_DIR; /* Location of autofs config file */ +const char *global_options; /* Global option, from command line */ + static char *pid_file = NULL; /* File in which to keep pid */ unsigned int random_selection; /* use random policy when selecting * which multi-mount host to mount */ @@ -1344,8 +1346,10 @@ " -d --debug log debuging info\n" " -D --define define global macro variable\n" /*" -f --foreground do not fork into background\n" */ - " -r --random-replicated-selection" + " -r --random-replicated-selection\n" " use ramdom replicated server selection\n" + " -O --global-options\n" + " specify global mount options\n" " -V --version print version, build config and exit\n" , program); } @@ -1431,7 +1435,7 @@ { int res, opt, status; unsigned ghost, logging; - unsigned foreground; + unsigned foreground, have_global_options; time_t timeout; time_t age = time(NULL); sigset_t allsigs; @@ -1445,6 +1449,7 @@ {"define", 1, 0, 'D'}, {"foreground", 0, 0, 'f'}, {"random-selection", 0, 0, 'r'}, + {"global-options", 1, 0, 'O'}, {"version", 0, 0, 'V'}, {0, 0, 0, 0} }; @@ -1460,10 +1465,12 @@ ghost = defaults_get_browse_mode(); logging = defaults_get_logging(); random_selection = 0; + global_options = NULL; + have_global_options = 0; foreground = 0; opterr = 0; - while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVr", long_options, NULL)) != EOF) { + while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:", long_options, NULL)) != EOF) { switch (opt) { case 'h': usage(); @@ -1501,6 +1508,16 @@ random_selection = 1; break; + case 'O': + if (!have_global_options) { + global_options = strdup(optarg); + have_global_options = 1; + break; + } + printf("%s: global options already specified.\n", + program); + break; + case '?': case ':': printf("%s: Ambiguous or unknown options\n", program); --- autofs-5.0.1/man/automount.8.in.cmd-global-options 2007-05-04 14:26:28.000000000 +0800 +++ autofs-5.0.1/man/automount.8.in 2007-05-04 14:27:28.000000000 +0800 @@ -53,6 +53,12 @@ Enables the use of ramdom selection when choosing a host from a list of replicated servers. .TP +.I "\-O, \-\-global-options" +Allows the specification of global mount options used for all master +map entries. These options will either replace or be appened to options +given in a master map entry depending on the APPEND_OPTIONS configuration +setting. +.TP .I "\-V, \-\-version" Display the version number, then exit. .SH ARGUMENTS