|
|
4d476f |
autofs-5.1.1 - factor out free multi map context
|
|
|
4d476f |
|
|
|
4d476f |
From: Ian Kent <raven@themaw.net>
|
|
|
4d476f |
|
|
|
4d476f |
Seperate out the free context function for the multi map module.
|
|
|
4d476f |
|
|
|
4d476f |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
4d476f |
---
|
|
|
4d476f |
modules/lookup_multi.c | 38 +++++++++++++++++++++++++++++---------
|
|
|
4d476f |
1 file changed, 29 insertions(+), 9 deletions(-)
|
|
|
4d476f |
|
|
|
4d476f |
diff --git a/modules/lookup_multi.c b/modules/lookup_multi.c
|
|
|
4d476f |
index 0ee20f5..36ace11 100644
|
|
|
4d476f |
--- a/modules/lookup_multi.c
|
|
|
4d476f |
+++ b/modules/lookup_multi.c
|
|
|
4d476f |
@@ -40,6 +40,32 @@ struct lookup_context {
|
|
|
4d476f |
|
|
|
4d476f |
int lookup_version = AUTOFS_LOOKUP_VERSION; /* Required by protocol */
|
|
|
4d476f |
|
|
|
4d476f |
+static int free_multi_context(struct lookup_context *ctxt)
|
|
|
4d476f |
+{
|
|
|
4d476f |
+ int rv;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ if (!ctxt)
|
|
|
4d476f |
+ return 0;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ rv = 0;
|
|
|
4d476f |
+ if (ctxt->m) {
|
|
|
4d476f |
+ int i;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ for (i = 0; i < ctxt->n; i++) {
|
|
|
4d476f |
+ if (ctxt->m[i].mod)
|
|
|
4d476f |
+ rv = rv || close_lookup(ctxt->m[i].mod);
|
|
|
4d476f |
+ if (ctxt->m[i].argv)
|
|
|
4d476f |
+ free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ free(ctxt->m);
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+
|
|
|
4d476f |
+ if (ctxt->argl)
|
|
|
4d476f |
+ free(ctxt->argl);
|
|
|
4d476f |
+
|
|
|
4d476f |
+ return rv;
|
|
|
4d476f |
+}
|
|
|
4d476f |
+
|
|
|
4d476f |
static struct lookup_mod *nss_open_lookup(const char *format, int argc, const char **argv)
|
|
|
4d476f |
{
|
|
|
4d476f |
struct list_head nsslist;
|
|
|
4d476f |
@@ -306,16 +332,10 @@ int lookup_mount(struct autofs_point *ap, const char *name, int name_len, void *
|
|
|
4d476f |
int lookup_done(void *context)
|
|
|
4d476f |
{
|
|
|
4d476f |
struct lookup_context *ctxt = (struct lookup_context *) context;
|
|
|
4d476f |
- int i, rv = 0;
|
|
|
4d476f |
+ int rv;
|
|
|
4d476f |
|
|
|
4d476f |
- for (i = 0; i < ctxt->n; i++) {
|
|
|
4d476f |
- if (ctxt->m[i].mod)
|
|
|
4d476f |
- rv = rv || close_lookup(ctxt->m[i].mod);
|
|
|
4d476f |
- if (ctxt->m[i].argv)
|
|
|
4d476f |
- free_argv(ctxt->m[i].argc, ctxt->m[i].argv);
|
|
|
4d476f |
- }
|
|
|
4d476f |
- free(ctxt->argl);
|
|
|
4d476f |
- free(ctxt->m);
|
|
|
4d476f |
+ rv = free_multi_context(ctxt);
|
|
|
4d476f |
free(ctxt);
|
|
|
4d476f |
+
|
|
|
4d476f |
return rv;
|
|
|
4d476f |
}
|