summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-01-17 14:50:54 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-01-17 16:13:33 +0800
commitb1d15f894473d4b1e90ad273487a432bcd637195 (patch)
tree46aa0587653d7ec9f02ed8067bf83bc6c2735e27
parent44e10d816427c001d60eb5e7b3e75b740e5a2823 (diff)
downloadtalos-petitboot-b1d15f894473d4b1e90ad273487a432bcd637195.tar.gz
talos-petitboot-b1d15f894473d4b1e90ad273487a432bcd637195.zip
discover: Don't rely on ctx->conf_url side-effect in user_event_parse_conf_url
Currently, user_event_parse_conf_url sets dc->conf_url if it detects we have a full URL (rather than a base URL). This is a little too subtle, so replace it with an explicit output parameter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/pxe-parser.c7
-rw-r--r--discover/user-event.c5
-rw-r--r--discover/user-event.h4
3 files changed, 11 insertions, 5 deletions
diff --git a/discover/pxe-parser.c b/discover/pxe-parser.c
index 2fc261b..e245f1b 100644
--- a/discover/pxe-parser.c
+++ b/discover/pxe-parser.c
@@ -101,6 +101,7 @@ static int pxe_parse(struct discover_context *dc)
char **pxe_conf_files, **filename;
struct pb_url *conf_url, *url;
struct conf_context *conf;
+ bool complete_url;
int len, rc;
char *buf;
@@ -121,11 +122,13 @@ static int pxe_parse(struct discover_context *dc)
parser_info = talloc_zero(conf, struct pxe_parser_info);
conf->parser_info = parser_info;
- conf_url = user_event_parse_conf_url(dc, dc->event);
+ conf_url = user_event_parse_conf_url(dc, dc->event, &complete_url);
if (!conf_url)
goto out_conf;
- if (dc->conf_url) {
+ if (complete_url) {
+ /* we have a complete URL; use this and we're done. */
+ dc->conf_url = conf_url;
rc = parser_request_url(dc, dc->conf_url, &buf, &len);
if (rc)
goto out_conf;
diff --git a/discover/user-event.c b/discover/user-event.c
index 69e6f7d..11a54df 100644
--- a/discover/user-event.c
+++ b/discover/user-event.c
@@ -230,7 +230,7 @@ static char *parse_ip_addr(struct discover_context *ctx, const char *ip)
}
struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
- struct event *event)
+ struct event *event, bool *is_complete)
{
const char *conffile, *host, *bootfile;
char *p, *basedir, *url_str;
@@ -255,7 +255,7 @@ struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
talloc_free(url_str);
}
- ctx->conf_url = url;
+ *is_complete = true;
} else {
host = parse_host_addr(event);
if (!host) {
@@ -284,6 +284,7 @@ struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
talloc_free(url_str);
talloc_free(basedir);
+ *is_complete = false;
}
return url;
diff --git a/discover/user-event.h b/discover/user-event.h
index 976c257..b892c9a 100644
--- a/discover/user-event.h
+++ b/discover/user-event.h
@@ -19,6 +19,8 @@
#if !defined(_PB_DISCOVER_USER_EVENT_H)
#define _PB_DISCOVER_USER_EVENT_H
+#include <stdbool.h>
+
#include "device-handler.h"
#define PBOOT_USER_EVENT_SOCKET "/tmp/petitboot.ev"
@@ -28,7 +30,7 @@ struct user_event;
struct waitset;
struct pb_url *user_event_parse_conf_url(struct discover_context *ctx,
- struct event *event);
+ struct event *event, bool *complete_url);
char **user_event_parse_conf_filenames(
struct discover_context *ctx, struct event *event);
struct user_event *user_event_init(struct waitset *waitset,
OpenPOWER on IntegriCloud