summaryrefslogtreecommitdiffstats
path: root/discover/platform-powerpc.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2014-01-29 17:41:04 +0800
committerJeremy Kerr <jk@ozlabs.org>2014-01-30 21:59:10 +0800
commit67e015d08f9a9f53b1ec0a6c301ce1a9516ea69a (patch)
tree404eeb691fc2ff97c12b8c0ed7a4998692819b6a /discover/platform-powerpc.c
parentc14b12980885edd035322cd3bc87efff444c39b1 (diff)
downloadpetitboot-67e015d08f9a9f53b1ec0a6c301ce1a9516ea69a.zip
petitboot-67e015d08f9a9f53b1ec0a6c301ce1a9516ea69a.tar.gz
platforms/powerpc: Check for a powerpc platform in the probe function
Currently, we're always assuming a powerpc platform, as the powerpc probe() function always returns true. This change adds a check for some bits we need to work on a powerpc platform. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover/platform-powerpc.c')
-rw-r--r--discover/platform-powerpc.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index e2a8631..7761769 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -4,6 +4,7 @@
#include <limits.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <talloc/talloc.h>
#include <list/list.h>
@@ -535,6 +536,20 @@ static int save_config(struct platform *p, struct config *config)
static bool probe(struct platform *p, void *ctx)
{
struct platform_powerpc *platform;
+ struct stat statbuf;
+ int rc;
+
+ /* we need a device tree and a working nvram binary */
+ rc = stat("/proc/device-tree", &statbuf);
+ if (rc)
+ return false;
+
+ if (!S_ISDIR(statbuf.st_mode))
+ return false;
+
+ rc = process_run_simple(ctx, "nvram", "--print-config", NULL);
+ if (!WIFEXITED(rc) || WEXITSTATUS(rc) != 0)
+ return false;
platform = talloc(ctx, struct platform_powerpc);
list_init(&platform->params);
OpenPOWER on IntegriCloud