]> git.ozlabs.org Git - petitboot/commitdiff
platforms/powerpc: Check for a powerpc platform in the probe function
authorJeremy Kerr <jk@ozlabs.org>
Wed, 29 Jan 2014 09:41:04 +0000 (17:41 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 13:59:10 +0000 (21:59 +0800)
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>
discover/platform-powerpc.c

index e2a86318f84803905c0bccc07519499410646a2b..776176956a8c9df777948728a9fcc15660998e2e 100644 (file)
@@ -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);