summaryrefslogtreecommitdiffstats
path: root/discover/native/native.c
blob: 964ad1d4d8f14bde146c444d5b377448d191500b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <assert.h>
#include <string.h>
#include <i18n/i18n.h>

#include <talloc/talloc.h>
#include <url/url.h>

#include <discover/resource.h>
#include <discover/parser.h>
#include <discover/parser-utils.h>

#include "native.h"

static const char *const native_conf_files[] = {
	"/boot/petitboot.conf",
	"/petitboot.conf",
	NULL
};

static int native_parse(struct discover_context *dc)
{
	const char * const *filename;
	struct native_parser *parser;
	int len, rc;
	char *buf;

	/* Support block device boot only at present */
	if (dc->event)
		return -1;

	for (filename = native_conf_files; *filename; filename++) {
		rc = parser_request_file(dc, dc->device, *filename, &buf, &len);
		if (rc)
			continue;

		parser = native_parser_create(dc);
		native_parser_parse(parser, *filename, buf, len);
		device_handler_status_dev_info(dc->handler, dc->device,
				_("Parsed native configuration from %s"),
				*filename);
		talloc_free(buf);
		talloc_free(parser);
		break;
	}

	return 0;
}

static struct parser native_parser = {
	.name			= "native",
	.parse			= native_parse,
	.resolve_resource	= resolve_devpath_resource,
};

register_parser(native_parser);
OpenPOWER on IntegriCloud