]> git.ozlabs.org Git - petitboot/blobdiff - discover/platform-powerpc.c
discover/network: Use platform definition for DHCP architecture ID
[petitboot] / discover / platform-powerpc.c
index e2a86318f84803905c0bccc07519499410646a2b..b0a35a7dfff4ea9a886513de2260658ea8cf42a6 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);
@@ -545,6 +560,7 @@ static bool probe(struct platform *p, void *ctx)
 
 static struct platform platform_powerpc = {
        .name           = "powerpc",
+       .dhcp_arch_id   = 0x000e,
        .probe          = probe,
        .load_config    = load_config,
        .save_config    = save_config,