|
|
306fa1 |
autofs-5.1.1 - implement reinit in parse modules
|
|
|
306fa1 |
|
|
|
306fa1 |
From: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
|
|
|
306fa1 |
Refactor the parse modules to add an implementation for the newly added
|
|
|
306fa1 |
reinit entry point.
|
|
|
306fa1 |
|
|
|
306fa1 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
306fa1 |
---
|
|
|
306fa1 |
modules/parse_hesiod.c | 1 +
|
|
|
306fa1 |
modules/parse_sun.c | 70 ++++++++++++++++++++++++++++++++++++------------
|
|
|
306fa1 |
2 files changed, 54 insertions(+), 17 deletions(-)
|
|
|
306fa1 |
|
|
|
306fa1 |
diff --git a/modules/parse_hesiod.c b/modules/parse_hesiod.c
|
|
|
306fa1 |
index 0b2b57f..a02da82 100644
|
|
|
306fa1 |
--- a/modules/parse_hesiod.c
|
|
|
306fa1 |
+++ b/modules/parse_hesiod.c
|
|
|
306fa1 |
@@ -258,6 +258,7 @@ static int parse_generic(struct autofs_point *ap,
|
|
|
306fa1 |
|
|
|
306fa1 |
int parse_init(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
+ *context = NULL;
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
|
|
|
306fa1 |
index 35d6da5..a164fba 100644
|
|
|
306fa1 |
--- a/modules/parse_sun.c
|
|
|
306fa1 |
+++ b/modules/parse_sun.c
|
|
|
306fa1 |
@@ -232,27 +232,15 @@ int expandsunent(const char *src, char *dst, const char *key,
|
|
|
306fa1 |
return len;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
-int parse_init(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
+static int do_init(int argc, const char *const *argv, struct parse_context *ctxt)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
- struct parse_context *ctxt;
|
|
|
306fa1 |
- char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
char *noptstr, *def, *val, *macros, *gbl_options;
|
|
|
306fa1 |
- const char *xopt;
|
|
|
306fa1 |
+ char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
int optlen, len, offset;
|
|
|
306fa1 |
+ const char *xopt;
|
|
|
306fa1 |
int i, bval;
|
|
|
306fa1 |
unsigned int append_options;
|
|
|
306fa1 |
|
|
|
306fa1 |
- /* Set up context and escape chain */
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- if (!(ctxt = (struct parse_context *) malloc(sizeof(struct parse_context)))) {
|
|
|
306fa1 |
- char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
306fa1 |
- logerr(MODPREFIX "malloc: %s", estr);
|
|
|
306fa1 |
- *context = NULL;
|
|
|
306fa1 |
- return 1;
|
|
|
306fa1 |
- }
|
|
|
306fa1 |
- *context = (void *) ctxt;
|
|
|
306fa1 |
-
|
|
|
306fa1 |
- *ctxt = default_context;
|
|
|
306fa1 |
optlen = 0;
|
|
|
306fa1 |
|
|
|
306fa1 |
/* Look for options and capture, and create new defines if we need to */
|
|
|
306fa1 |
@@ -359,7 +347,6 @@ int parse_init(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
306fa1 |
kill_context(ctxt);
|
|
|
306fa1 |
logerr(MODPREFIX "%s", estr);
|
|
|
306fa1 |
- *context = NULL;
|
|
|
306fa1 |
return 1;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
ctxt->optstr = noptstr;
|
|
|
306fa1 |
@@ -391,9 +378,36 @@ int parse_init(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
}
|
|
|
306fa1 |
}
|
|
|
306fa1 |
options_done:
|
|
|
306fa1 |
+
|
|
|
306fa1 |
debug(LOGOPT_NONE,
|
|
|
306fa1 |
MODPREFIX "init gathered global options: %s", ctxt->optstr);
|
|
|
306fa1 |
|
|
|
306fa1 |
+ return 0;
|
|
|
306fa1 |
+}
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+int parse_init(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
+{
|
|
|
306fa1 |
+ struct parse_context *ctxt;
|
|
|
306fa1 |
+ char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ *context = NULL;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ /* Set up context and escape chain */
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ ctxt = (struct parse_context *) malloc(sizeof(struct parse_context));
|
|
|
306fa1 |
+ if (!ctxt) {
|
|
|
306fa1 |
+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
306fa1 |
+ logerr(MODPREFIX "malloc: %s", estr);
|
|
|
306fa1 |
+ return 1;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ *ctxt = default_context;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if (do_init(argc, argv, ctxt)) {
|
|
|
306fa1 |
+ free(ctxt);
|
|
|
306fa1 |
+ return 1;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
/* We only need this once. NFS mounts are so common that we cache
|
|
|
306fa1 |
this module. */
|
|
|
306fa1 |
instance_mutex_lock();
|
|
|
306fa1 |
@@ -404,17 +418,39 @@ options_done:
|
|
|
306fa1 |
init_ctr++;
|
|
|
306fa1 |
} else {
|
|
|
306fa1 |
kill_context(ctxt);
|
|
|
306fa1 |
- *context = NULL;
|
|
|
306fa1 |
instance_mutex_unlock();
|
|
|
306fa1 |
return 1;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
}
|
|
|
306fa1 |
instance_mutex_unlock();
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ *context = (void *) ctxt;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|
|
|
306fa1 |
int parse_reinit(int argc, const char *const *argv, void **context)
|
|
|
306fa1 |
{
|
|
|
306fa1 |
+ struct parse_context *ctxt = (struct parse_context *) *context;
|
|
|
306fa1 |
+ struct parse_context *new;
|
|
|
306fa1 |
+ char buf[MAX_ERR_BUF];
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ new = (struct parse_context *) malloc(sizeof(struct parse_context));
|
|
|
306fa1 |
+ if (!new) {
|
|
|
306fa1 |
+ char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
|
|
|
306fa1 |
+ logerr(MODPREFIX "malloc: %s", estr);
|
|
|
306fa1 |
+ return 1;
|
|
|
306fa1 |
+ }
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ *new = default_context;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ if (do_init(argc, argv, new))
|
|
|
306fa1 |
+ return 1;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ kill_context(ctxt);
|
|
|
306fa1 |
+
|
|
|
306fa1 |
+ *context = (void *) new;
|
|
|
306fa1 |
+
|
|
|
306fa1 |
return 0;
|
|
|
306fa1 |
}
|
|
|
306fa1 |
|