X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=devices%2Fnative-parser.c;h=4f94d9da343cda29d9298bc23e4a42f19f16ebe3;hp=f47fdca0c3ac2871e7124b96847426962dc99a5b;hb=f6de8493cf6645f8da027671f935cf22f8008a1b;hpb=f60d0b2e7dbd9d85980866c68d0f87b6bc823663 diff --git a/devices/native-parser.c b/devices/native-parser.c index f47fdca..4f94d9d 100644 --- a/devices/native-parser.c +++ b/devices/native-parser.c @@ -13,20 +13,6 @@ static struct device *dev; static const char *mountpoint; 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 +47,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 = join_paths(mountpoint, value); else if (streq(name, "icon")) - opt->icon_file = prepend_mountpoint(value); + opt->icon_file = join_paths(mountpoint, value); else if (streq(name, "initrd")) - opt->initrd_file = prepend_mountpoint(value); + opt->initrd_file = join_paths(mountpoint, value); else if (streq(name, "args")) opt->boot_args = strdup(value); @@ -86,7 +72,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 = join_paths(mountpoint, value); } static int parameter(char *param_name, char *param_value) @@ -102,17 +88,20 @@ static int parameter(char *param_name, char *param_value) int parse(const char *devicepath, const char *_mountpoint) { char *filepath; + int rc; mountpoint = _mountpoint; - filepath = prepend_mountpoint(conf_filename); + filepath = join_paths(mountpoint, conf_filename); cur_opt = NULL; dev = malloc(sizeof(*dev)); memset(dev, 0, sizeof(*dev)); dev->id = strdup(devicepath); - pm_process(filepath, section, parameter); + rc = pm_process(filepath, section, parameter); + if (!rc) + return 0; if (cur_opt) { add_boot_option(cur_opt);