X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=devices%2Fkboot-parser.c;h=df2e7620e13ad8ea40a735aaa04da60881f43de1;hp=d449ef673e4b5c8d4cc218e79d9dd619a1257373;hb=a57e4ef92b8e590643a325d309511306c5b941a9;hpb=5395466a3522eccf73e2f617dc4a18bff98b290f;ds=inline diff --git a/devices/kboot-parser.c b/devices/kboot-parser.c index d449ef6..df2e762 100644 --- a/devices/kboot-parser.c +++ b/devices/kboot-parser.c @@ -15,7 +15,7 @@ #define buf_size 1024 -static const char *mountpoint; +static const char *devpath; static int param_is_ignored(const char *param) { @@ -82,7 +82,7 @@ struct global_option { }; -struct global_option global_options[] = { +static struct global_option global_options[] = { { .name = "root" }, { .name = "initrd" }, { .name = "video" }, @@ -138,13 +138,13 @@ static int parse_option(struct boot_option *opt, char *config) /* if there's no space, it's only a kernel image with no params */ if (!pos) { - opt->boot_image_file = join_paths(mountpoint, config); + opt->boot_image_file = resolve_path(config, devpath); opt->description = strdup(config); return 1; } *pos = 0; - opt->boot_image_file = join_paths(mountpoint, config); + opt->boot_image_file = resolve_path(config, devpath); cmdline = malloc(buf_size); *cmdline = 0; @@ -179,7 +179,7 @@ static int parse_option(struct boot_option *opt, char *config) free(cmdline); cmdline = tmp; - opt->initrd_file = join_paths(mountpoint, initrd); + opt->initrd_file = resolve_path(initrd, devpath); } if (root) { @@ -197,7 +197,8 @@ static int parse_option(struct boot_option *opt, char *config) pb_log("kboot cmdline: %s\n", cmdline); opt->boot_args = cmdline; - asprintf(&opt->description, "%s %s", config, cmdline); + asprintf(&opt->description, "%s %s", + config, opt->boot_args); return 1; } @@ -235,16 +236,16 @@ static void parse_buf(struct device *dev, char *buf) } } -static int parse(const char *devicepath, const char *_mountpoint) +static int parse(const char *device) { char *filepath, *buf; int fd, len, rc = 0; struct stat stat; struct device *dev; - mountpoint = _mountpoint; + devpath = device; - filepath = join_paths(mountpoint, "/etc/kboot.conf"); + filepath = resolve_path("/etc/kboot.conf", devpath); fd = open(filepath, O_RDONLY); if (fd < 0) @@ -264,7 +265,7 @@ static int parse(const char *devicepath, const char *_mountpoint) dev = malloc(sizeof(*dev)); memset(dev, 0, sizeof(*dev)); - dev->id = strdup(devicepath); + dev->id = strdup(device); dev->icon_file = strdup(generic_icon_file(guess_device_type())); parse_buf(dev, buf);