X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=devices%2Fyaboot-parser.c;h=fc55047809b09ad6e8b8fc8fc533406fca363498;hb=238549fe012d19681ede101f02fc4f653402e550;hp=ee1b992dca0b17e56edee06af3fc4687828c1d53;hpb=747a0d462cf02ec2b6649f5a3d9b759424d793f8;p=petitboot diff --git a/devices/yaboot-parser.c b/devices/yaboot-parser.c index ee1b992..fc55047 100644 --- a/devices/yaboot-parser.c +++ b/devices/yaboot-parser.c @@ -1,5 +1,5 @@ -#include "udev-helper.h" +#include "parser.h" #include "params.h" #include "yaboot-cfg.h" @@ -15,7 +15,6 @@ static struct device *dev; static const char *mountpoint; -static char partition_mntpoint[PATH_MAX]; static char *defimage; char * @@ -86,20 +85,6 @@ make_params(char *label, char *params) return buffer; } -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; -} - static int check_and_add_device(struct device *dev) { if (!dev->icon_file) @@ -117,13 +102,13 @@ void process_image(char *label) opt.name = label; cfgopt = cfg_get_strg(label, "image"); - opt.boot_image_file = prepend_mountpoint(cfgopt); + opt.boot_image_file = resolve_path(cfgopt, mountpoint); if (cfgopt == defimage) - printf("This one is default. What do we do about it?\n"); + pb_log("This one is default. What do we do about it?\n"); cfgopt = cfg_get_strg(label, "initrd"); if (cfgopt) - opt.initrd_file = prepend_mountpoint(cfgopt); + opt.initrd_file = resolve_path(cfgopt, mountpoint); opt.boot_args = make_params(label, NULL); @@ -145,12 +130,12 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint) mountpoint = _mountpoint; - filepath = prepend_mountpoint("/etc/yaboot.conf"); + filepath = join_paths(mountpoint, "/etc/yaboot.conf"); fd = open(filepath, O_RDONLY); if (fd < 0) { free(filepath); - filepath = prepend_mountpoint("/yaboot.conf"); + filepath = join_paths(mountpoint, "/yaboot.conf"); fd = open(filepath, O_RDONLY); if (fd < 0) @@ -178,7 +163,7 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint) close(fd); if (cfg_parse(filepath, conf_file, conf_len)) { - printf("Error parsing yaboot.conf\n"); + pb_log("Error parsing yaboot.conf\n"); return 0; } @@ -196,8 +181,8 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint) } dev->icon_file = strdup(generic_icon_file(guess_device_type())); - /* Mount the 'partition' which is what all the image filenames - are relative to */ + /* If we have a 'partiton=' directive, update the default mountpoint + * to use that instead of the current mountpoint */ tmpstr = cfg_get_strg(0, "partition"); if (tmpstr) { char *endp; @@ -217,16 +202,9 @@ static int yaboot_parse(const char *devicepath, const char *_mountpoint) /* and add our own... */ sprintf(endp+1, "%d", partnr); - /* FIXME: udev may not have created the device node - yet. And on removal, unmount_device() only unmounts - it once, while in fact it may be mounted twice. */ - if (mount_device(new_dev, partition_mntpoint)) { - printf("Error mounting image partition\n"); - return 0; - } - mountpoint = partition_mntpoint; + mountpoint = mountpoint_for_device(new_dev); dev->id = new_dev; - } + } } defimage = cfg_get_default();