blspec: honour default/once entries again and move them to a different place
Support for default/once entries was lost earlier. This fixes this and also looks for default/once entries in the loader directory instead of the loader parent directory. This keeps the bootloader spec files together under a common loader directory. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
61eebbcf8e
commit
c5ced0d7c7
|
@ -308,6 +308,29 @@ out:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static char *read_default_once(const char *root, const char *name)
|
||||
{
|
||||
char *str, *res;
|
||||
|
||||
/* Compat: default/once was under root directly */
|
||||
str = read_file_line("%s/%s", root, name);
|
||||
|
||||
if (!str)
|
||||
str = read_file_line("%s/loader/%s", root, name);
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
res = strrchr(str, '/');
|
||||
if (!res)
|
||||
return str;
|
||||
|
||||
res = xstrdup(res);
|
||||
free(str);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* blspec_scan_directory - scan over a directory
|
||||
*
|
||||
|
@ -323,7 +346,7 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
|
|||
char *abspath;
|
||||
int ret, found = 0;
|
||||
const char *dirname = "loader/entries";
|
||||
char *entry_default = NULL, *entry_once = NULL, *name, *nfspath = NULL;
|
||||
char *entry_default = NULL, *entry_once = NULL, *nfspath = NULL;
|
||||
|
||||
nfspath = parse_nfs_url(root);
|
||||
if (!IS_ERR(nfspath))
|
||||
|
@ -331,8 +354,8 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
|
|||
|
||||
pr_info("%s: %s %s\n", __func__, root, dirname);
|
||||
|
||||
entry_default = read_file_line("%s/default", root);
|
||||
entry_once = read_file_line("%s/once", root);
|
||||
entry_default = read_default_once(root, "default");
|
||||
entry_once = read_default_once(root, "once");
|
||||
|
||||
abspath = asprintf("%s/%s", root, dirname);
|
||||
|
||||
|
@ -398,12 +421,10 @@ int blspec_scan_directory(struct blspec *blspec, const char *root)
|
|||
|
||||
found++;
|
||||
|
||||
name = asprintf("%s/%s", dirname, d->d_name);
|
||||
if (entry_default && !strcmp(name, entry_default))
|
||||
if (entry_default && !strcmp(d->d_name, entry_default))
|
||||
entry->boot_default = true;
|
||||
if (entry_once && !strcmp(name, entry_once))
|
||||
if (entry_once && !strcmp(d->d_name, entry_once))
|
||||
entry->boot_once = true;
|
||||
free(name);
|
||||
|
||||
if (entry->cdev) {
|
||||
devname = xstrdup(dev_name(entry->cdev->dev));
|
||||
|
|
|
@ -1118,7 +1118,7 @@ static int do_set_once_default(const char *name, int entry)
|
|||
return -errno;
|
||||
}
|
||||
|
||||
dprintf(fd, "loader/entries/%s\n", e->config_file);
|
||||
dprintf(fd, "%s\n", e->config_file);
|
||||
|
||||
ret = close(fd);
|
||||
if (ret)
|
||||
|
|
Loading…
Reference in New Issue