diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-09 14:17:05 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-09 14:17:05 +0200 |
commit | ff47ec5d8793b1b1fa8aa9d856d81cac117918df (patch) | |
tree | 89142e22d00ae588803b9a2f5d3078fc24d0457c /common | |
parent | ca0e44de5e4af8d328c88c17549db9f9f69a2f56 (diff) | |
parent | 70013eb56ddaacb518aeb4d7d35f627c5387d557 (diff) | |
download | barebox-ff47ec5d8793b1b1fa8aa9d856d81cac117918df.tar.gz barebox-ff47ec5d8793b1b1fa8aa9d856d81cac117918df.tar.xz |
Merge branch 'for-next/misc'
Diffstat (limited to 'common')
-rw-r--r-- | common/blspec.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/common/blspec.c b/common/blspec.c index 6171461a72..2c682e1990 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -420,6 +420,30 @@ out: } /* + * entry_is_match_machine_id - check if a bootspec entry is match with + * the machine id given by global variable. + * + * returns true if the entry is match, false otherwise + */ + +static bool entry_is_match_machine_id(struct blspec_entry *entry) +{ + int ret = true; + const char *env_machineid = getenv_nonempty("global.boot.machine_id"); + + if (env_machineid) { + const char *machineid = blspec_entry_var_get(entry, "machine-id"); + if (!machineid || strcmp(machineid, env_machineid)) { + pr_debug("ignoring entry with missmatched machine-id " \ + "\"%s\" != \"%s\"\n", env_machineid, machineid); + ret = false; + } + } + + return ret; +} + +/* * blspec_scan_directory - scan over a directory * * Given a root path collects all bootentries entries found under /bootentries/entries/. @@ -504,6 +528,11 @@ int blspec_scan_directory(struct bootentries *bootentries, const char *root) continue; } + if (!entry_is_match_machine_id(entry)) { + blspec_entry_free(&entry->entry); + continue; + } + found++; if (entry->cdev && entry->cdev->dev) { @@ -756,4 +785,4 @@ static int blspec_init(void) { return bootentry_register_provider(blspec_bootentry_provider); } -device_initcall(blspec_init);
\ No newline at end of file +device_initcall(blspec_init); |