[PATCH RFC 2/3] discover: Add read_bootdev for comma separated nvram values

Samuel Mendoza-Jonas sam.mj at au1.ibm.com
Tue Dec 16 10:44:00 AEDT 2014


Following commits allow the user to define several ordered autoboot
options. To retain backwards compatability, these will reuse the
petiboot,bootdev parameter as list of comma separated device names
or UUIDs.

Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
---
 discover/platform-powerpc.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 0440eb4..2829066 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -385,6 +385,47 @@ static void populate_network_config(struct platform_powerpc *platform,
 	talloc_free(val);
 }
 
+static int read_bootdev(void *ctx, char **pos, struct autoboot_option *opt)
+{
+	char *delim = strchr(*pos, ',');
+	int len, prefix = 0, rc = -1;
+	enum device_type type;
+
+	if (!strncmp(*pos, "uuid:", strlen("uuid:"))) {
+		prefix = strlen("uuid:");
+		opt->boot_type = BOOT_DEVICE_UUID;
+		rc = 0;
+	} else if (!strncmp(*pos, "mac:", strlen("mac:"))) {
+		prefix = strlen("mac:");
+		opt->boot_type = BOOT_DEVICE_UUID;
+		rc = 0;
+	} else {
+		type = find_device_type(*pos);
+		if (type != DEVICE_TYPE_UNKNOWN) {
+			opt->type = type;
+			opt->boot_type = BOOT_DEVICE_TYPE;
+			rc = 0;
+		}
+	}
+
+	if (opt->boot_type == BOOT_DEVICE_UUID) {
+		if (delim)
+			len = (int)(delim - *pos) - prefix;
+		else
+			len = strlen(*pos);
+
+		opt->uuid = talloc_strndup(ctx, *pos + prefix, len);
+	}
+
+	/* Always advance pointer to next option or end */
+	if (delim)
+		*pos = delim + 1;
+	else
+		*pos = strchr(*pos, '\0');
+
+	return rc;
+}
+
 static void populate_bootdev_config(struct platform_powerpc *platform,
 		struct config *config)
 
-- 
1.9.3



More information about the Petitboot mailing list