summaryrefslogtreecommitdiffstats
path: root/common/blspec.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/blspec.c')
-rw-r--r--common/blspec.c73
1 files changed, 31 insertions, 42 deletions
diff --git a/common/blspec.c b/common/blspec.c
index 18005569ff..bf98e6b29a 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -203,16 +203,18 @@ static char *parse_nfs_url(const char *url)
if (ip == 0)
goto out;
- hostpath = asprintf("%s:%s", ip_to_string(ip), path);
+ hostpath = basprintf("%s:%s", ip_to_string(ip), path);
prevpath = nfs_find_mountpath(hostpath);
if (prevpath) {
mountpath = xstrdup(prevpath);
} else {
- mountpath = asprintf("/mnt/nfs-%s-blspec-%08x", host, rand());
+ mountpath = basprintf("/mnt/nfs-%s-blspec-%08x", host,
+ rand());
if (port)
- options = asprintf("mountport=%s,port=%s", port, port);
+ options = basprintf("mountport=%s,port=%s", port,
+ port);
ret = make_directory(mountpath);
if (ret)
@@ -278,7 +280,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
if (!strcmp(devicetree, "none"))
return true;
- filename = asprintf("%s/%s", abspath, devicetree);
+ filename = basprintf("%s/%s", abspath, devicetree);
fdt = read_file(filename, &size);
if (!fdt) {
@@ -338,7 +340,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
entry_default = read_file_line("%s/default", root);
entry_once = read_file_line("%s/once", root);
- abspath = asprintf("%s/%s", root, dirname);
+ abspath = basprintf("%s/%s", root, dirname);
dir = opendir(abspath);
if (!dir) {
@@ -356,7 +358,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
if (*d->d_name == '.')
continue;
- configname = asprintf("%s/%s", abspath, d->d_name);
+ configname = basprintf("%s/%s", abspath, d->d_name);
dot = strrchr(configname, '.');
if (!dot) {
@@ -402,7 +404,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
found++;
- name = asprintf("%s/%s", dirname, d->d_name);
+ name = basprintf("%s/%s", dirname, d->d_name);
if (entry_default && !strcmp(name, entry_default))
entry->boot_default = true;
if (entry_once && !strcmp(name, entry_once))
@@ -415,10 +417,10 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
hwdevname = xstrdup(dev_name(entry->cdev->dev->parent));
}
- entry->me.display = asprintf("%-20s %-20s %s",
- devname ? devname : "",
- hwdevname ? hwdevname : "",
- blspec_entry_var_get(entry, "title"));
+ entry->me.display = basprintf("%-20s %-20s %s",
+ devname ? devname : "",
+ hwdevname ? hwdevname : "",
+ blspec_entry_var_get(entry, "title"));
free(devname);
free(hwdevname);
@@ -637,29 +639,6 @@ int blspec_scan_devicename(struct blspec *blspec, const char *devname)
return blspec_scan_device(blspec, dev);
}
-static int blspec_append_root(struct blspec_entry *entry)
-{
- const char *appendroot;
- char *rootarg;
-
- appendroot = blspec_entry_var_get(entry, "linux-appendroot");
- if (!appendroot || strcmp(appendroot, "true"))
- return 0;
-
- rootarg = path_get_linux_rootarg(entry->rootpath);
- if (IS_ERR(rootarg)) {
- pr_err("Getting root argument for %s failed with: %s\n",
- entry->rootpath, strerrorp(rootarg));
- return PTR_ERR(rootarg);
- }
-
- globalvar_add_simple("linux.bootargs.dyn.blspec.appendroot", rootarg);
-
- free(rootarg);
-
- return 0;
-}
-
/*
* blspec_boot - boot an entry
*
@@ -671,6 +650,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
{
int ret;
const char *abspath, *devicetree, *options, *initrd, *linuximage;
+ const char *appendroot;
struct bootm_data data = {
.initrd_address = UIMAGE_INVALID_ADDRESS,
.os_address = UIMAGE_SOME_ADDRESS,
@@ -691,7 +671,7 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
else
abspath = "";
- data.os_file = asprintf("%s/%s", abspath, linuximage);
+ data.os_file = basprintf("%s/%s", abspath, linuximage);
if (devicetree) {
if (!strcmp(devicetree, "none")) {
@@ -699,25 +679,34 @@ int blspec_boot(struct blspec_entry *entry, int verbose, int dryrun)
if (node)
of_delete_node(node);
} else {
- data.oftree_file = asprintf("%s/%s", abspath,
- devicetree);
+ data.oftree_file = basprintf("%s/%s", abspath,
+ devicetree);
}
}
if (initrd)
- data.initrd_file = asprintf("%s/%s", abspath, initrd);
+ data.initrd_file = basprintf("%s/%s", abspath, initrd);
globalvar_add_simple("linux.bootargs.dyn.blspec", options);
- ret = blspec_append_root(entry);
- if (ret)
- goto err_out;
+ appendroot = blspec_entry_var_get(entry, "linux-appendroot");
+ if (appendroot) {
+ int val;
+
+ ret = strtobool(appendroot, &val);
+ if (ret) {
+ pr_err("Invalid value \"%s\" for appendroot option\n",
+ appendroot);
+ goto err_out;
+ }
+ data.appendroot = val;
+ }
pr_info("booting %s from %s\n", blspec_entry_var_get(entry, "title"),
entry->cdev ? dev_name(entry->cdev->dev) : "none");
if (entry->boot_once) {
- char *s = asprintf("%s/once", abspath);
+ char *s = basprintf("%s/once", abspath);
ret = unlink(s);
if (ret)