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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#include <petitboot-paths.h>
#include <stdlib.h>
#include <string.h>
#include "parser.h"
extern struct parser native_parser;
extern struct parser yaboot_parser;
extern struct parser kboot_parser;
/* array of parsers, ordered by priority */
static struct parser *parsers[] = {
&native_parser,
&yaboot_parser,
&kboot_parser,
NULL
};
void iterate_parsers(const char *devpath, const char *mountpoint)
{
int i;
pb_log("trying parsers for %s@%s\n", devpath, mountpoint);
for (i = 0; parsers[i]; i++) {
pb_log("\ttrying parser '%s'\n", parsers[i]->name);
/* just use a dummy device path for now */
if (parsers[i]->parse(devpath, mountpoint))
/*return*/;
}
pb_log("\tno boot_options found\n");
}
/* convenience functions for parsers */
void free_device(struct device *dev)
{
if (!dev)
return;
if (dev->id)
free(dev->id);
if (dev->name)
free(dev->name);
if (dev->description)
free(dev->description);
if (dev->icon_file)
free(dev->icon_file);
free(dev);
}
void free_boot_option(struct boot_option *opt)
{
if (!opt)
return;
if (opt->name)
free(opt->name);
if (opt->description)
free(opt->description);
if (opt->icon_file)
free(opt->icon_file);
if (opt->boot_image_file)
free(opt->boot_image_file);
if (opt->initrd_file)
free(opt->initrd_file);
if (opt->boot_args)
free(opt->boot_args);
free(opt);
}
char *join_paths(const char *a, const char *b)
{
char *full_path;
full_path = malloc(strlen(a) + strlen(b) + 2);
strcpy(full_path, a);
if (b[0] != '/')
strcat(full_path, "/");
strcat(full_path, b);
return full_path;
}
const char *generic_icon_file(enum generic_icon_type type)
{
switch (type) {
case ICON_TYPE_DISK:
return artwork_pathname("hdd.png");
case ICON_TYPE_USB:
return artwork_pathname("usbpen.png");
case ICON_TYPE_OPTICAL:
return artwork_pathname("cdrom.png");
case ICON_TYPE_NETWORK:
case ICON_TYPE_UNKNOWN:
break;
}
return artwork_pathname("hdd.png");
}
|