- char *filepath;
- char *conf_file;
- char *tmpstr;
- ssize_t conf_len;
- int fd;
- struct stat st;
- char *label;
-
- devpath = strdup(device);
-
- filepath = resolve_path("/etc/yaboot.conf", devpath);
-
- fd = open(filepath, O_RDONLY);
- if (fd < 0) {
- free(filepath);
- filepath = resolve_path("/yaboot.conf", devpath);
- fd = open(filepath, O_RDONLY);
-
- if (fd < 0)
- return 0;
- }
-
- if (fstat(fd, &st)) {
- close(fd);
- return 0;
- }
-
- conf_file = malloc(st.st_size+1);
- if (!conf_file) {
- close(fd);
- return 0;
- }
-
- conf_len = read(fd, conf_file, st.st_size);
- if (conf_len < 0) {
- close(fd);
- return 0;
- }
- conf_file[conf_len] = 0;
-
- close(fd);
-
- if (cfg_parse(filepath, conf_file, conf_len)) {
- pb_log("Error parsing yaboot.conf\n");
- return 0;
- }
-
- free(filepath);
-
- dev = malloc(sizeof(*dev));
- memset(dev, 0, sizeof(*dev));
- dev->id = strdup(devpath);
- if (cfg_get_strg(0, "init-message")) {
- char *newline;
- dev->description = strdup(cfg_get_strg(0, "init-message"));
- newline = strchr(dev->description, '\n');
- if (newline)
- *newline = 0;
- }
- dev->icon_file = strdup(generic_icon_file(guess_device_type()));
-
- /* If we have a 'partiton=' directive, update the default devpath
- * to use that instead of the current device */
- tmpstr = cfg_get_strg(0, "partition");
- if (tmpstr) {
- char *endp;
- int partnr = strtol(tmpstr, &endp, 10);
- if (endp != tmpstr && !*endp) {
- char *new_dev, *tmp;
-
- new_dev = malloc(strlen(devpath) + strlen(tmpstr) + 1);
- if (!new_dev)
- return 0;
-
- strcpy(new_dev, devpath);
-
- /* Strip digits (partition number) from string */
- endp = new_dev + strlen(devpath) - 1;
- while (isdigit(*endp))
- *(endp--) = 0;
-
- /* and add our own... */
- sprintf(endp + 1, "%d", partnr);
-
- tmp = devpath;
- devpath = parse_device_path(new_dev, devpath);
- free(tmp);
- free(new_dev);
+ struct yaboot_state *state = conf->parser_info;
+ struct discover_boot_option *opt = state->opt;
+ struct fixed_pair {
+ const char *image;
+ const char *initrd;
+ };
+ static const struct fixed_pair suse_fp32 = {
+ .image = "/suseboot/vmlinux32",
+ .initrd = "/suseboot/initrd32",
+ };
+ static const struct fixed_pair suse_fp64 = {
+ .image = "/suseboot/vmlinux64",
+ .initrd = "/suseboot/initrd64",
+ };
+ const struct fixed_pair *suse_fp;
+
+ /* fixup for bare values */
+
+ if (!name)
+ name = value;
+
+ if (!state->globals_done && conf_set_global_option(conf, name, value))
+ return;
+
+ /* image */
+ if (streq(name, "image")) {
+ /* an image section finishes our global defintions */
+ state->globals_done = 1;
+
+ /* First finish any previous image. */
+ if (opt)
+ yaboot_finish(conf);
+
+ /* Then start the new image. */
+ opt = state_start_new_option(conf, state);
+
+ state->boot_image = talloc_strdup(state, value);
+
+ return;
+ }
+
+ /* Special processing for SUSE install CD. */
+
+ if (streq(name, "image[32bit]"))
+ suse_fp = &suse_fp32;
+ else if (streq(name, "image[64bit]"))
+ suse_fp = &suse_fp64;
+ else
+ suse_fp = NULL;
+
+ if (suse_fp) {
+ /* First finish any previous image. */
+ if (opt)
+ yaboot_finish(conf);
+
+ /* Then start the new image. */
+ opt = state_start_new_option(conf, state);
+
+ if (*value == '/') {
+ state->boot_image = talloc_strdup(state, value);
+ } else {
+ state->boot_image = talloc_strdup(state,
+ suse_fp->image);
+ state->initrd = talloc_strdup(state, suse_fp->initrd);