]> git.ozlabs.org Git - petitboot/blobdiff - utils/hooks/30-dtb-updates.c
discover/device-handler: Allow process_url request to be pending
[petitboot] / utils / hooks / 30-dtb-updates.c
index aff3844dd5e9f613e8d1717085e108408eb76c9d..e161d8794c1ad96d696ea99802274fb12107958a 100644 (file)
@@ -515,7 +515,10 @@ static int set_stdout(struct offb_ctx *ctx)
        if (strncmp(boot_console, "/dev/", strlen("/dev/")) != 0) {
                /* We already have the full path */
                stdout_path = talloc_strdup(ctx, boot_console);
-       } else if (strstr(boot_console, "tty") != NULL) {
+               /* Check for a tty* console but don't accidentally catch
+                * ttyS* consoles */
+       } else if (strstr(boot_console, "tty") != NULL &&
+                       strstr(boot_console, "ttyS") == NULL) {
                fprintf(stderr, "TTY recognised: %s\n", boot_console);
                stdout_path = get_vga_path(ctx);
        } else {
@@ -576,20 +579,10 @@ static int write_devicetree(struct offb_ctx *ctx)
        return rc;
 }
 
-
-int main(void)
+static int set_offb(struct offb_ctx *ctx)
 {
-       struct offb_ctx *ctx;
        int rc;
 
-       ctx = talloc_zero(NULL, struct offb_ctx);
-
-       ctx->dtb_name = getenv("boot_dtb");
-       if (!ctx->dtb_name) {
-               talloc_free(ctx);
-               return EXIT_SUCCESS;
-       }
-
        rc = load_dtb(ctx);
        if (rc)
                goto out;
@@ -605,14 +598,39 @@ int main(void)
        rc = populate_devicetree(ctx);
        if (rc)
                goto out;
+out:
+       return rc;
+}
 
-       rc = set_stdout(ctx);
-       if (rc)
-               goto out;
 
-       rc = write_devicetree(ctx);
+int main(void)
+{
+       struct offb_ctx *ctx;
+       int rc;
+
+       ctx = talloc_zero(NULL, struct offb_ctx);
+
+       ctx->dtb_name = getenv("boot_dtb");
+       if (!ctx->dtb_name) {
+               talloc_free(ctx);
+               return EXIT_SUCCESS;
+       }
+
+       if (set_offb(ctx)) {
+               warn("Failed offb setup step");
+               rc = -1;
+       }
+
+       if (set_stdout(ctx)) {
+               warn("Failed stdout setup step\n");
+               rc = -1;
+       }
+
+       if (write_devicetree(ctx)) {
+               warn("Failed to write back device tree\n");
+               rc = -1;
+       }
 
-out:
        talloc_free(ctx);
        return rc ? EXIT_FAILURE : EXIT_SUCCESS;
 }