]> git.ozlabs.org Git - petitboot/blobdiff - devices/native-parser.c
Make kboot_parser global options array static
[petitboot] / devices / native-parser.c
index bb1ca51e3e3e720bc9ab81588eb28dddd4d0e70a..24713b19542da150de6b101c2adab1b036245f2b 100644 (file)
@@ -1,6 +1,7 @@
 
-#include "udev-helper.h"
+#include "parser.h"
 #include "params.h"
+#include "paths.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -10,23 +11,9 @@ const char *conf_filename = "/boot/petitboot.conf";
 
 static struct boot_option *cur_opt;
 static struct device *dev;
-static const char *mountpoint;
+static const char *devpath;
 int device_added;
 
-static char *prepend_mountpoint(const char *path)
-{
-       char *full_path;
-
-       full_path = malloc(strlen(path) + strlen(mountpoint) + 2);
-
-       strcpy(full_path, mountpoint);
-       if (path[0] != '/')
-               strcat(full_path, "/");
-       strcat(full_path, path);
-
-       return full_path;
-}
-
 int check_and_add_device(struct device *dev)
 {
        if (!dev->icon_file)
@@ -61,13 +48,13 @@ static void set_boot_option_parameter(struct boot_option *opt,
                opt->description = strdup(value);
 
        else if (streq(name, "image"))
-               opt->boot_image_file = prepend_mountpoint(value);
+               opt->boot_image_file = resolve_path(value, devpath);
 
        else if (streq(name, "icon"))
-               opt->icon_file = prepend_mountpoint(value);
+               opt->icon_file = resolve_path(value, devpath);
 
        else if (streq(name, "initrd"))
-               opt->initrd_file = prepend_mountpoint(value);
+               opt->initrd_file =resolve_path(value, devpath);
 
        else if (streq(name, "args"))
                opt->boot_args = strdup(value);
@@ -86,7 +73,7 @@ static void set_device_parameter(struct device *dev,
                dev->description = strdup(value);
 
        else if (streq(name, "icon"))
-               dev->icon_file = prepend_mountpoint(value);
+               dev->icon_file = resolve_path(value, devpath);
 }
 
 static int parameter(char *param_name, char *param_value)
@@ -99,19 +86,17 @@ static int parameter(char *param_name, char *param_value)
 }
 
 
-int parse(const char *devicepath, const char *_mountpoint)
+int parse(const char *device)
 {
        char *filepath;
        int rc;
 
-       mountpoint = _mountpoint;
-
-       filepath = prepend_mountpoint(conf_filename);
+       filepath = resolve_path(conf_filename, device);
 
        cur_opt = NULL;
        dev = malloc(sizeof(*dev));
        memset(dev, 0, sizeof(*dev));
-       dev->id = strdup(devicepath);
+       dev->id = strdup(device);
 
        rc = pm_process(filepath, section, parameter);
        if (!rc)